1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <sys/types.h> |
---|
15 | #include <sys/wait.h> |
---|
16 | #if HAVE_SYS_MMAN_H |
---|
17 | /* POSIX mandates mprotect in sys/mman.h, but newlib doesn't have this */ |
---|
18 | #include <sys/mman.h> |
---|
19 | #endif |
---|
20 | #include <pthread.h> |
---|
21 | |
---|
22 | #define CONFIGURE_INIT |
---|
23 | #include "system.h" |
---|
24 | #include "tmacros.h" |
---|
25 | |
---|
26 | #include <aio.h> |
---|
27 | #include <time.h> |
---|
28 | #include <unistd.h> |
---|
29 | #include <sched.h> |
---|
30 | |
---|
31 | const char rtems_test_name[] = "PSXENOSYS"; |
---|
32 | |
---|
33 | #if !HAVE_DECL_MPROTECT |
---|
34 | extern int mprotect(const void *addr, size_t len, int prot); |
---|
35 | #endif |
---|
36 | #if !HAVE_DECL_PTHREAD_ATFORK |
---|
37 | extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); |
---|
38 | #endif |
---|
39 | |
---|
40 | void check_enosys(int status); |
---|
41 | |
---|
42 | void check_enosys(int status) |
---|
43 | { |
---|
44 | if ( (status == -1) && (errno == ENOSYS) ) |
---|
45 | return; |
---|
46 | puts( "ERROR -- did not return ENOSYS as expected" ); |
---|
47 | rtems_test_exit(0); |
---|
48 | } |
---|
49 | |
---|
50 | void *POSIX_Init( |
---|
51 | void *argument |
---|
52 | ) |
---|
53 | { |
---|
54 | int sc; |
---|
55 | |
---|
56 | TEST_BEGIN(); |
---|
57 | |
---|
58 | puts( "lio_listio -- ENOSYS" ); |
---|
59 | sc = lio_listio( 0, NULL, 0, NULL ); |
---|
60 | check_enosys( sc ); |
---|
61 | |
---|
62 | puts( "aio_suspend -- ENOSYS" ); |
---|
63 | sc = aio_suspend( NULL, 0, NULL ); |
---|
64 | check_enosys( sc ); |
---|
65 | |
---|
66 | puts( "clock_getcpuclockid -- ENOSYS" ); |
---|
67 | sc = clock_getcpuclockid( 0, NULL ); |
---|
68 | check_enosys( sc ); |
---|
69 | |
---|
70 | puts( "execl -- ENOSYS" ); |
---|
71 | sc = execl( NULL, NULL, (char*)0 ); |
---|
72 | check_enosys( sc ); |
---|
73 | |
---|
74 | puts( "execle -- ENOSYS" ); |
---|
75 | sc = execle( NULL, NULL, (char*)0, NULL ); |
---|
76 | check_enosys( sc ); |
---|
77 | |
---|
78 | puts( "execlp -- ENOSYS" ); |
---|
79 | sc = execlp( NULL, NULL, (char*)0 ); |
---|
80 | check_enosys( sc ); |
---|
81 | |
---|
82 | puts( "execv -- ENOSYS" ); |
---|
83 | sc = execv( NULL, NULL ); |
---|
84 | check_enosys( sc ); |
---|
85 | |
---|
86 | puts( "execve -- ENOSYS" ); |
---|
87 | sc = execve( NULL, NULL, NULL ); |
---|
88 | check_enosys( sc ); |
---|
89 | |
---|
90 | puts( "execvp -- ENOSYS" ); |
---|
91 | sc = execvp( NULL, NULL ); |
---|
92 | check_enosys( sc ); |
---|
93 | |
---|
94 | puts( "fork -- ENOSYS" ); |
---|
95 | sc = fork(); |
---|
96 | check_enosys( sc ); |
---|
97 | |
---|
98 | puts( "pthread_atfork -- ENOSYS" ); |
---|
99 | sc = pthread_atfork( NULL, NULL, NULL ); |
---|
100 | check_enosys( sc ); |
---|
101 | |
---|
102 | puts( "pthread_getcpuclockid -- ENOSYS" ); |
---|
103 | sc = pthread_getcpuclockid( 0, NULL ); |
---|
104 | check_enosys( sc ); |
---|
105 | |
---|
106 | puts( "sched_setparam -- ENOSYS" ); |
---|
107 | sc = sched_setparam( 0, NULL ); |
---|
108 | check_enosys( sc ); |
---|
109 | |
---|
110 | puts( "sched_getparam -- ENOSYS" ); |
---|
111 | sc = sched_getparam( 0, NULL ); |
---|
112 | check_enosys( sc ); |
---|
113 | |
---|
114 | puts( "sched_setscheduler -- ENOSYS" ); |
---|
115 | sc = sched_setscheduler( 0, 0, NULL ); |
---|
116 | check_enosys( sc ); |
---|
117 | |
---|
118 | puts( "sched_getscheduler -- ENOSYS" ); |
---|
119 | sc = sched_getscheduler( 0 ); |
---|
120 | check_enosys( sc ); |
---|
121 | |
---|
122 | puts( "wait -- ENOSYS" ); |
---|
123 | sc = wait( NULL ); |
---|
124 | check_enosys( sc ); |
---|
125 | |
---|
126 | puts( "waitpid -- ENOSYS" ); |
---|
127 | sc = waitpid( 0, NULL, 0 ); |
---|
128 | check_enosys( sc ); |
---|
129 | |
---|
130 | puts( "mprotect -- stub implementation - OK" ); |
---|
131 | sc = mprotect( NULL, 0, 0 ); |
---|
132 | posix_service_failed( sc, "mprotect" ); |
---|
133 | |
---|
134 | puts( "vfork -- stub implementation - OK" ); |
---|
135 | sc = vfork(); |
---|
136 | if ( sc != -1 ) { |
---|
137 | puts( "vfork did not return -1" ); |
---|
138 | rtems_test_exit( 0 ); |
---|
139 | } |
---|
140 | |
---|
141 | TEST_END(); |
---|
142 | rtems_test_exit( 0 ); |
---|
143 | |
---|
144 | return NULL; /* just so the compiler thinks we returned something */ |
---|
145 | } |
---|