1 | /* |
---|
2 | * COPYRIGHT (c) 2014. |
---|
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 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | #define MESSAGE_SIZE (sizeof(long) * 4) |
---|
18 | |
---|
19 | const char rtems_test_name[] = "SP SEMAPHORE ERROR 01"; |
---|
20 | |
---|
21 | rtems_task Init( |
---|
22 | rtems_task_argument argument |
---|
23 | ) |
---|
24 | { |
---|
25 | rtems_status_code status; |
---|
26 | |
---|
27 | TEST_BEGIN(); |
---|
28 | |
---|
29 | Semaphore_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' ); |
---|
30 | Semaphore_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' ); |
---|
31 | Semaphore_name[ 3 ] = rtems_build_name( 'S', 'M', '3', ' ' ); |
---|
32 | |
---|
33 | /* release overflow */ |
---|
34 | status = rtems_semaphore_create( |
---|
35 | Semaphore_name[ 1 ], |
---|
36 | UINT32_MAX, |
---|
37 | RTEMS_COUNTING_SEMAPHORE, |
---|
38 | 0, |
---|
39 | &Semaphore_id[ 1 ] |
---|
40 | ); |
---|
41 | fatal_directive_status( |
---|
42 | status, |
---|
43 | RTEMS_SUCCESSFUL, |
---|
44 | "rtems_semaphore_create" |
---|
45 | ); |
---|
46 | puts( "TA1 - rtems_semaphore_create - RTEMS_SUCCESSFUL" ); |
---|
47 | status = rtems_semaphore_release( Semaphore_id[ 1 ] ); |
---|
48 | fatal_directive_status( |
---|
49 | status, |
---|
50 | RTEMS_UNSATISFIED, |
---|
51 | "rtems_semaphore_release" |
---|
52 | ); |
---|
53 | puts( "TA1 - rtems_semaphore_release - RTEMS_UNSATISFIED" ); |
---|
54 | status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); |
---|
55 | fatal_directive_status( |
---|
56 | status, |
---|
57 | RTEMS_SUCCESSFUL, |
---|
58 | "rtems_semaphore_delete" |
---|
59 | ); |
---|
60 | puts( "TA1 - rtems_semaphore_delete - RTEMS_SUCCESSFUL" ); |
---|
61 | |
---|
62 | /* invalid name */ |
---|
63 | status = rtems_semaphore_create( |
---|
64 | 0, |
---|
65 | 1, |
---|
66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
67 | RTEMS_NO_PRIORITY, |
---|
68 | &Junk_id |
---|
69 | ); |
---|
70 | fatal_directive_status( |
---|
71 | status, |
---|
72 | RTEMS_INVALID_NAME, |
---|
73 | "rtems_semaphore_create with illegal name" |
---|
74 | ); |
---|
75 | puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_NAME" ); |
---|
76 | |
---|
77 | /* NULL Id parameter */ |
---|
78 | status = rtems_semaphore_create( |
---|
79 | Semaphore_name[ 1 ], |
---|
80 | 1, |
---|
81 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
82 | RTEMS_NO_PRIORITY, |
---|
83 | NULL |
---|
84 | ); |
---|
85 | fatal_directive_status( |
---|
86 | status, |
---|
87 | RTEMS_INVALID_ADDRESS, |
---|
88 | "rtems_semaphore_create with NULL param" |
---|
89 | ); |
---|
90 | puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_ADDRESS" ); |
---|
91 | |
---|
92 | /* OK */ |
---|
93 | status = rtems_semaphore_create( |
---|
94 | Semaphore_name[ 1 ], |
---|
95 | 1, |
---|
96 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
97 | RTEMS_NO_PRIORITY, |
---|
98 | &Semaphore_id[ 1 ] |
---|
99 | ); |
---|
100 | directive_failed( status, "rtems_semaphore_create" ); |
---|
101 | puts( "TA1 - rtems_semaphore_create - 1 - RTEMS_SUCCESSFUL" ); |
---|
102 | |
---|
103 | status = rtems_semaphore_create( |
---|
104 | Semaphore_name[ 2 ], |
---|
105 | 1, |
---|
106 | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, |
---|
107 | RTEMS_NO_PRIORITY, |
---|
108 | &Semaphore_id[ 2 ] |
---|
109 | ); |
---|
110 | directive_failed( status, "rtems_semaphore_create" ); |
---|
111 | puts( "TA1 - rtems_semaphore_create - 2 - RTEMS_SUCCESSFUL" ); |
---|
112 | |
---|
113 | do { |
---|
114 | status = rtems_semaphore_create( |
---|
115 | Semaphore_name[ 3 ], |
---|
116 | 1, |
---|
117 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
118 | RTEMS_NO_PRIORITY, |
---|
119 | &Junk_id |
---|
120 | ); |
---|
121 | } while (status == RTEMS_SUCCESSFUL); |
---|
122 | |
---|
123 | fatal_directive_status( |
---|
124 | status, |
---|
125 | RTEMS_TOO_MANY, |
---|
126 | "rtems_semaphore_create of too many" |
---|
127 | ); |
---|
128 | puts( "TA1 - rtems_semaphore_create - 3 - RTEMS_TOO_MANY" ); |
---|
129 | |
---|
130 | status = rtems_semaphore_create( |
---|
131 | Semaphore_name[ 1 ], |
---|
132 | 1, |
---|
133 | RTEMS_INHERIT_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO, |
---|
134 | RTEMS_NO_PRIORITY, |
---|
135 | &Junk_id |
---|
136 | ); |
---|
137 | fatal_directive_status( |
---|
138 | status, |
---|
139 | RTEMS_NOT_DEFINED, |
---|
140 | "rtems_semaphore_create of RTEMS_FIFO RTEMS_INHERIT_PRIORITY" |
---|
141 | ); |
---|
142 | puts( "TA1 - rtems_semaphore_create - FIFO and inherit - RTEMS_NOT_DEFINED" ); |
---|
143 | |
---|
144 | status = rtems_semaphore_create( |
---|
145 | Semaphore_name[ 1 ], |
---|
146 | 1, |
---|
147 | RTEMS_PRIORITY_CEILING | RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO, |
---|
148 | RTEMS_NO_PRIORITY, |
---|
149 | &Junk_id |
---|
150 | ); |
---|
151 | fatal_directive_status( |
---|
152 | status, |
---|
153 | RTEMS_NOT_DEFINED, |
---|
154 | "rtems_semaphore_create of RTEMS_FIFO RTEMS_CEILING_PRIORITY" |
---|
155 | ); |
---|
156 | puts( "TA1 - rtems_semaphore_create - FIFO and ceiling - RTEMS_NOT_DEFINED" ); |
---|
157 | |
---|
158 | status = rtems_semaphore_create( |
---|
159 | Semaphore_name[ 1 ], |
---|
160 | 1, |
---|
161 | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING | |
---|
162 | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY, |
---|
163 | 10, |
---|
164 | &Junk_id |
---|
165 | ); |
---|
166 | fatal_directive_status( |
---|
167 | status, |
---|
168 | RTEMS_NOT_DEFINED, |
---|
169 | "rtems_semaphore_create of binary with ceiling and inherit" |
---|
170 | ); |
---|
171 | puts( |
---|
172 | "TA1 - rtems_semaphore_create - ceiling and inherit - RTEMS_NOT_DEFINED" ); |
---|
173 | |
---|
174 | status = rtems_semaphore_create( |
---|
175 | Semaphore_name[ 1 ], |
---|
176 | 1, |
---|
177 | RTEMS_INHERIT_PRIORITY | RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY, |
---|
178 | RTEMS_NO_PRIORITY, |
---|
179 | &Junk_id |
---|
180 | ); |
---|
181 | fatal_directive_status( |
---|
182 | status, |
---|
183 | RTEMS_NOT_DEFINED, |
---|
184 | "rtems_semaphore_create of RTEMS_COUNTING_SEMAPHORE RTEMS_INHERIT_PRIORITY" |
---|
185 | ); |
---|
186 | puts( "TA1 - rtems_semaphore_create - RTEMS_NOT_DEFINED" ); |
---|
187 | |
---|
188 | status = rtems_semaphore_create( |
---|
189 | Semaphore_name[ 1 ], |
---|
190 | 2, |
---|
191 | RTEMS_BINARY_SEMAPHORE, |
---|
192 | RTEMS_NO_PRIORITY, |
---|
193 | &Junk_id |
---|
194 | ); |
---|
195 | fatal_directive_status( |
---|
196 | status, |
---|
197 | RTEMS_INVALID_NUMBER, |
---|
198 | "rtems_semaphore_create of binary semaphore with count > 1" |
---|
199 | ); |
---|
200 | puts( "TA1 - rtems_semaphore_create - RTEMS_INVALID_NUMBER" ); |
---|
201 | |
---|
202 | status = rtems_semaphore_delete( 100 ); |
---|
203 | fatal_directive_status( |
---|
204 | status, |
---|
205 | RTEMS_INVALID_ID, |
---|
206 | "rtems_semaphore_delete with illegal id" |
---|
207 | ); |
---|
208 | puts( "TA1 - rtems_semaphore_delete - RTEMS_INVALID_ID" ); |
---|
209 | |
---|
210 | status = rtems_semaphore_delete( rtems_build_id( 1, 0, 0, 0 ) ); |
---|
211 | fatal_directive_status( |
---|
212 | status, |
---|
213 | RTEMS_INVALID_ID, |
---|
214 | "rtems_semaphore_delete with local illegal id" |
---|
215 | ); |
---|
216 | puts( "TA1 - rtems_semaphore_delete - local RTEMS_INVALID_ID" ); |
---|
217 | |
---|
218 | status = rtems_semaphore_ident( 100, RTEMS_SEARCH_ALL_NODES, &Junk_id ); |
---|
219 | fatal_directive_status( |
---|
220 | status, |
---|
221 | RTEMS_INVALID_NAME, |
---|
222 | "rtems_semaphore_ident will illegal name (local)" |
---|
223 | ); |
---|
224 | puts( "TA1 - rtems_semaphore_ident - global RTEMS_INVALID_NAME" ); |
---|
225 | |
---|
226 | status = rtems_semaphore_ident( 100, 1, &Junk_id ); |
---|
227 | fatal_directive_status( |
---|
228 | status, |
---|
229 | RTEMS_INVALID_NAME, |
---|
230 | "rtems_semaphore_ident will illegal name (global)" |
---|
231 | ); |
---|
232 | puts( "TA1 - rtems_semaphore_ident - local RTEMS_INVALID_NAME" ); |
---|
233 | |
---|
234 | status = rtems_semaphore_release( 100 ); |
---|
235 | fatal_directive_status( |
---|
236 | status, |
---|
237 | RTEMS_INVALID_ID, |
---|
238 | "rtems_semaphore_release with illegal id" |
---|
239 | ); |
---|
240 | puts( "TA1 - rtems_semaphore_release - RTEMS_INVALID_ID" ); |
---|
241 | |
---|
242 | status = rtems_semaphore_flush( 100 ); |
---|
243 | fatal_directive_status( |
---|
244 | status, |
---|
245 | RTEMS_INVALID_ID, |
---|
246 | "rtems_semaphore_flush with illegal id" |
---|
247 | ); |
---|
248 | puts( "TA1 - rtems_semaphore_flush - RTEMS_INVALID_ID" ); |
---|
249 | |
---|
250 | TEST_END(); |
---|
251 | } |
---|