5
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * This test exercises the posix_devctl() method. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * COPYRIGHT (c) 2016. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.org/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifdef HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #define _POSIX_26_C_SOURCE |
---|
21 | #include "tmacros.h" |
---|
22 | #include <errno.h> |
---|
23 | #include <sys/ioctl.h> |
---|
24 | #include <stdlib.h> |
---|
25 | |
---|
26 | #include <devctl.h> |
---|
27 | |
---|
28 | #include <unistd.h> |
---|
29 | #include <fcntl.h> |
---|
30 | |
---|
31 | const char rtems_test_name[] = "PSXDEVCTL 1"; |
---|
32 | |
---|
33 | /* forward declarations to avoid warnings */ |
---|
34 | int test_main(void); |
---|
35 | |
---|
36 | /* |
---|
37 | * main entry point to the test |
---|
38 | */ |
---|
39 | |
---|
40 | #if defined(__rtems__) |
---|
41 | int test_main(void) |
---|
42 | #else |
---|
43 | int main( |
---|
44 | int argc, |
---|
45 | char **argv |
---|
46 | ) |
---|
47 | #endif |
---|
48 | { |
---|
49 | int status; |
---|
50 | int fd; |
---|
51 | int dcmd; |
---|
52 | int dev_data; |
---|
53 | void *dev_data_ptr; |
---|
54 | size_t nbyte; |
---|
55 | int dev_info; |
---|
56 | |
---|
57 | TEST_BEGIN(); |
---|
58 | |
---|
59 | puts( "posix_devctl() FIONBIO on stdin return dev_info -- EBADF" ); |
---|
60 | fd = 0; |
---|
61 | dcmd = FIONBIO; |
---|
62 | dev_data_ptr = &dev_data; |
---|
63 | nbyte = sizeof(dev_data); |
---|
64 | status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, &dev_info ); |
---|
65 | rtems_test_assert( status == -1 ); |
---|
66 | rtems_test_assert( errno == EBADF ); |
---|
67 | rtems_test_assert( dev_info == 0 ); |
---|
68 | |
---|
69 | puts( "posix_devctl() FIONBIO on stdin NULL dev_info -- EBADF" ); |
---|
70 | fd = 0; |
---|
71 | dcmd = FIONBIO; |
---|
72 | dev_data_ptr = NULL; |
---|
73 | nbyte = 0; |
---|
74 | status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL ); |
---|
75 | rtems_test_assert( status == -1 ); |
---|
76 | rtems_test_assert( errno == EBADF ); |
---|
77 | |
---|
78 | TEST_END(); |
---|
79 | exit(0); |
---|
80 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.