1 | /* |
---|
2 | * Copyright (c) 2018 embedded brains GmbH & Co. KG |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.com/license/LICENSE. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifdef HAVE_CONFIG_H |
---|
10 | #include "config.h" |
---|
11 | #endif |
---|
12 | |
---|
13 | #include <rtems.h> |
---|
14 | #include <rtems/score/objectimpl.h> |
---|
15 | #include <rtems/sysinit.h> |
---|
16 | |
---|
17 | #include <tmacros.h> |
---|
18 | |
---|
19 | const char rtems_test_name[] = "SPCONFIG 2"; |
---|
20 | |
---|
21 | static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E'); |
---|
22 | |
---|
23 | static void test_barrier_create(void) |
---|
24 | { |
---|
25 | rtems_status_code sc; |
---|
26 | rtems_id id; |
---|
27 | |
---|
28 | sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id); |
---|
29 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
30 | } |
---|
31 | |
---|
32 | static void test_barrier_delete(void) |
---|
33 | { |
---|
34 | rtems_status_code sc; |
---|
35 | rtems_id id; |
---|
36 | |
---|
37 | sc = rtems_barrier_delete(0); |
---|
38 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
39 | |
---|
40 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0); |
---|
41 | sc = rtems_barrier_delete(id); |
---|
42 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
43 | } |
---|
44 | |
---|
45 | static void test_barrier_get(void) |
---|
46 | { |
---|
47 | rtems_status_code sc; |
---|
48 | rtems_id id; |
---|
49 | |
---|
50 | sc = rtems_barrier_wait(0, RTEMS_NO_TIMEOUT); |
---|
51 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
52 | |
---|
53 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_BARRIERS, 1, 0); |
---|
54 | sc = rtems_barrier_wait(id, RTEMS_NO_TIMEOUT); |
---|
55 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
56 | } |
---|
57 | |
---|
58 | static void test_message_queue_create(void) |
---|
59 | { |
---|
60 | rtems_status_code sc; |
---|
61 | rtems_id id; |
---|
62 | |
---|
63 | sc = rtems_message_queue_create( |
---|
64 | name, |
---|
65 | 1, |
---|
66 | 1, |
---|
67 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
68 | &id |
---|
69 | ); |
---|
70 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
71 | } |
---|
72 | |
---|
73 | static void test_message_queue_delete(void) |
---|
74 | { |
---|
75 | rtems_status_code sc; |
---|
76 | rtems_id id; |
---|
77 | |
---|
78 | sc = rtems_message_queue_delete(0); |
---|
79 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
80 | |
---|
81 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0); |
---|
82 | sc = rtems_message_queue_delete(id); |
---|
83 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
84 | } |
---|
85 | |
---|
86 | static void test_message_queue_get(void) |
---|
87 | { |
---|
88 | rtems_status_code sc; |
---|
89 | rtems_id id; |
---|
90 | uint32_t count; |
---|
91 | |
---|
92 | sc = rtems_message_queue_flush(0, &count); |
---|
93 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
94 | |
---|
95 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0); |
---|
96 | sc = rtems_message_queue_flush(id, &count); |
---|
97 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
98 | } |
---|
99 | |
---|
100 | static void test_partition_create(void) |
---|
101 | { |
---|
102 | rtems_status_code sc; |
---|
103 | rtems_id id; |
---|
104 | long buf[32]; |
---|
105 | |
---|
106 | sc = rtems_partition_create( |
---|
107 | name, |
---|
108 | buf, |
---|
109 | sizeof(buf), |
---|
110 | sizeof(buf), |
---|
111 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
112 | &id |
---|
113 | ); |
---|
114 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
115 | } |
---|
116 | |
---|
117 | static void test_partition_delete(void) |
---|
118 | { |
---|
119 | rtems_status_code sc; |
---|
120 | rtems_id id; |
---|
121 | |
---|
122 | sc = rtems_partition_delete(0); |
---|
123 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
124 | |
---|
125 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0); |
---|
126 | sc = rtems_partition_delete(id); |
---|
127 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
128 | } |
---|
129 | |
---|
130 | static void test_partition_get(void) |
---|
131 | { |
---|
132 | rtems_status_code sc; |
---|
133 | rtems_id id; |
---|
134 | |
---|
135 | sc = rtems_partition_return_buffer(0, NULL); |
---|
136 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
137 | |
---|
138 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0); |
---|
139 | sc = rtems_partition_return_buffer(id, NULL); |
---|
140 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
141 | } |
---|
142 | |
---|
143 | static void test_rate_monotonic_create(void) |
---|
144 | { |
---|
145 | rtems_status_code sc; |
---|
146 | rtems_id id; |
---|
147 | |
---|
148 | sc = rtems_rate_monotonic_create(name, &id); |
---|
149 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
150 | } |
---|
151 | |
---|
152 | static void test_rate_monotonic_delete(void) |
---|
153 | { |
---|
154 | rtems_status_code sc; |
---|
155 | rtems_id id; |
---|
156 | |
---|
157 | sc = rtems_rate_monotonic_delete(0); |
---|
158 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
159 | |
---|
160 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0); |
---|
161 | sc = rtems_rate_monotonic_delete(id); |
---|
162 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
163 | } |
---|
164 | |
---|
165 | static void test_rate_monotonic_get(void) |
---|
166 | { |
---|
167 | rtems_status_code sc; |
---|
168 | rtems_id id; |
---|
169 | |
---|
170 | sc = rtems_rate_monotonic_cancel(0); |
---|
171 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
172 | |
---|
173 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0); |
---|
174 | sc = rtems_rate_monotonic_cancel(id); |
---|
175 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
176 | } |
---|
177 | |
---|
178 | static void test_region_create(void) |
---|
179 | { |
---|
180 | rtems_status_code sc; |
---|
181 | rtems_id id; |
---|
182 | long buf[32]; |
---|
183 | |
---|
184 | sc = rtems_region_create( |
---|
185 | name, |
---|
186 | buf, |
---|
187 | sizeof(buf), |
---|
188 | 1, |
---|
189 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
190 | &id |
---|
191 | ); |
---|
192 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
193 | } |
---|
194 | |
---|
195 | static void test_region_delete(void) |
---|
196 | { |
---|
197 | rtems_status_code sc; |
---|
198 | rtems_id id; |
---|
199 | |
---|
200 | sc = rtems_region_delete(0); |
---|
201 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
202 | |
---|
203 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0); |
---|
204 | sc = rtems_region_delete(id); |
---|
205 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
206 | } |
---|
207 | |
---|
208 | static void test_region_get(void) |
---|
209 | { |
---|
210 | rtems_status_code sc; |
---|
211 | rtems_id id; |
---|
212 | |
---|
213 | sc = rtems_region_return_segment(0, NULL); |
---|
214 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
215 | |
---|
216 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0); |
---|
217 | sc = rtems_region_return_segment(id, NULL); |
---|
218 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
219 | } |
---|
220 | |
---|
221 | static void test_semaphore_create(void) |
---|
222 | { |
---|
223 | rtems_status_code sc; |
---|
224 | rtems_id id; |
---|
225 | |
---|
226 | sc = rtems_semaphore_create( |
---|
227 | name, |
---|
228 | 0, |
---|
229 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
230 | 0, |
---|
231 | &id |
---|
232 | ); |
---|
233 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
234 | } |
---|
235 | |
---|
236 | static void test_semaphore_delete(void) |
---|
237 | { |
---|
238 | rtems_status_code sc; |
---|
239 | rtems_id id; |
---|
240 | |
---|
241 | sc = rtems_semaphore_delete(0); |
---|
242 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
243 | |
---|
244 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0); |
---|
245 | sc = rtems_semaphore_delete(id); |
---|
246 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
247 | } |
---|
248 | |
---|
249 | static void test_semaphore_get(void) |
---|
250 | { |
---|
251 | rtems_status_code sc; |
---|
252 | rtems_id id; |
---|
253 | |
---|
254 | sc = rtems_semaphore_release(0); |
---|
255 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
256 | |
---|
257 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0); |
---|
258 | sc = rtems_semaphore_release(id); |
---|
259 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
260 | } |
---|
261 | |
---|
262 | static void test_task_create(void) |
---|
263 | { |
---|
264 | rtems_status_code sc; |
---|
265 | rtems_id id; |
---|
266 | |
---|
267 | sc = rtems_task_create( |
---|
268 | name, |
---|
269 | 1, |
---|
270 | RTEMS_MINIMUM_STACK_SIZE, |
---|
271 | RTEMS_DEFAULT_MODES, |
---|
272 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
273 | &id |
---|
274 | ); |
---|
275 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
276 | } |
---|
277 | |
---|
278 | static void test_task_delete(void) |
---|
279 | { |
---|
280 | rtems_status_code sc; |
---|
281 | rtems_id id; |
---|
282 | |
---|
283 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0); |
---|
284 | sc = rtems_task_delete(id); |
---|
285 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
286 | } |
---|
287 | |
---|
288 | static void test_task_get(void) |
---|
289 | { |
---|
290 | rtems_status_code sc; |
---|
291 | rtems_id id; |
---|
292 | |
---|
293 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0); |
---|
294 | sc = rtems_task_resume(id); |
---|
295 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
296 | } |
---|
297 | |
---|
298 | static void test_timer_create(void) |
---|
299 | { |
---|
300 | rtems_status_code sc; |
---|
301 | rtems_id id; |
---|
302 | |
---|
303 | sc = rtems_timer_create(name, &id); |
---|
304 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
305 | } |
---|
306 | |
---|
307 | static void test_timer_delete(void) |
---|
308 | { |
---|
309 | rtems_status_code sc; |
---|
310 | rtems_id id; |
---|
311 | |
---|
312 | sc = rtems_timer_delete(0); |
---|
313 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
314 | |
---|
315 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0); |
---|
316 | sc = rtems_timer_delete(id); |
---|
317 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
318 | } |
---|
319 | |
---|
320 | static void test_timer_get(void) |
---|
321 | { |
---|
322 | rtems_status_code sc; |
---|
323 | rtems_id id; |
---|
324 | |
---|
325 | sc = rtems_timer_reset(0); |
---|
326 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
327 | |
---|
328 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0); |
---|
329 | sc = rtems_timer_reset(id); |
---|
330 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
331 | } |
---|
332 | |
---|
333 | static void test_user_extensions_create(void) |
---|
334 | { |
---|
335 | rtems_status_code sc; |
---|
336 | rtems_id id; |
---|
337 | rtems_extensions_table table; |
---|
338 | |
---|
339 | memset(&table, 0, sizeof(table)); |
---|
340 | sc = rtems_extension_create(name, &table, &id); |
---|
341 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
342 | } |
---|
343 | |
---|
344 | static void test_user_extensions_delete(void) |
---|
345 | { |
---|
346 | rtems_status_code sc; |
---|
347 | rtems_id id; |
---|
348 | |
---|
349 | sc = rtems_extension_delete(0); |
---|
350 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
351 | |
---|
352 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_EXTENSIONS, 1, 0); |
---|
353 | sc = rtems_extension_delete(id); |
---|
354 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
355 | } |
---|
356 | |
---|
357 | static void test_id_to_name(rtems_id api, rtems_id cls, rtems_id idx, bool *found) |
---|
358 | { |
---|
359 | rtems_status_code sc; |
---|
360 | rtems_id id; |
---|
361 | rtems_name name_of_id; |
---|
362 | |
---|
363 | id = rtems_build_id(api, cls, 1, idx); |
---|
364 | sc = rtems_object_get_classic_name(id, &name_of_id); |
---|
365 | |
---|
366 | if (sc == RTEMS_SUCCESSFUL) { |
---|
367 | if (name_of_id == rtems_build_name('U', 'I', '1', ' ')) { |
---|
368 | rtems_test_assert(id == rtems_task_self()); |
---|
369 | rtems_test_assert(!found[0]); |
---|
370 | found[0] = true; |
---|
371 | } else { |
---|
372 | rtems_test_assert(name_of_id == rtems_build_name('I', 'D', 'L', 'E')); |
---|
373 | rtems_test_assert(!found[1]); |
---|
374 | found[1] = true; |
---|
375 | } |
---|
376 | } else { |
---|
377 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | static void test_some_id_to_name(void) |
---|
382 | { |
---|
383 | rtems_id api; |
---|
384 | bool found[2]; |
---|
385 | |
---|
386 | found[0] = false; |
---|
387 | found[1] = false; |
---|
388 | |
---|
389 | for (api = 0; api < 8; ++api) { |
---|
390 | rtems_id cls; |
---|
391 | |
---|
392 | for (cls = 0; cls < 32; ++cls) { |
---|
393 | test_id_to_name(api, cls, 0, found); |
---|
394 | test_id_to_name(api, cls, 1, found); |
---|
395 | test_id_to_name(api, cls, 2, found); |
---|
396 | test_id_to_name(api, cls, 65534, found); |
---|
397 | test_id_to_name(api, cls, 65535, found); |
---|
398 | } |
---|
399 | } |
---|
400 | |
---|
401 | rtems_test_assert(found[0]); |
---|
402 | rtems_test_assert(found[1]); |
---|
403 | } |
---|
404 | |
---|
405 | static void Init(rtems_task_argument arg) |
---|
406 | { |
---|
407 | test_barrier_create(); |
---|
408 | test_barrier_delete(); |
---|
409 | test_barrier_get(); |
---|
410 | test_message_queue_create(); |
---|
411 | test_message_queue_delete(); |
---|
412 | test_message_queue_get(); |
---|
413 | test_partition_create(); |
---|
414 | test_partition_delete(); |
---|
415 | test_partition_get(); |
---|
416 | test_rate_monotonic_create(); |
---|
417 | test_rate_monotonic_delete(); |
---|
418 | test_rate_monotonic_get(); |
---|
419 | test_region_create(); |
---|
420 | test_region_delete(); |
---|
421 | test_region_get(); |
---|
422 | test_semaphore_create(); |
---|
423 | test_semaphore_delete(); |
---|
424 | test_semaphore_get(); |
---|
425 | test_task_create(); |
---|
426 | test_task_delete(); |
---|
427 | test_task_get(); |
---|
428 | test_timer_create(); |
---|
429 | test_timer_delete(); |
---|
430 | test_timer_get(); |
---|
431 | test_user_extensions_create(); |
---|
432 | test_user_extensions_delete(); |
---|
433 | test_some_id_to_name(); |
---|
434 | TEST_END(); |
---|
435 | rtems_test_exit(0); |
---|
436 | } |
---|
437 | |
---|
438 | static void before_object_information_initialization(void) |
---|
439 | { |
---|
440 | rtems_print_printer_printk(&rtems_test_printer); |
---|
441 | TEST_BEGIN(); |
---|
442 | test_barrier_get(); |
---|
443 | test_message_queue_get(); |
---|
444 | test_partition_get(); |
---|
445 | test_rate_monotonic_get(); |
---|
446 | test_semaphore_get(); |
---|
447 | test_task_get(); |
---|
448 | test_timer_get(); |
---|
449 | } |
---|
450 | |
---|
451 | RTEMS_SYSINIT_ITEM( |
---|
452 | before_object_information_initialization, |
---|
453 | RTEMS_SYSINIT_INITIAL_EXTENSIONS, |
---|
454 | RTEMS_SYSINIT_ORDER_LAST |
---|
455 | ); |
---|
456 | |
---|
457 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
458 | |
---|
459 | #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM |
---|
460 | |
---|
461 | #define CONFIGURE_DISABLE_NEWLIB_REENTRANCY |
---|
462 | |
---|
463 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
464 | |
---|
465 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
466 | |
---|
467 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
468 | |
---|
469 | #define CONFIGURE_INIT |
---|
470 | |
---|
471 | #include <rtems/confdefs.h> |
---|