1 | /* |
---|
2 | * Copyright (c) 2018 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems.h> |
---|
20 | #include <rtems/score/objectimpl.h> |
---|
21 | |
---|
22 | #include <tmacros.h> |
---|
23 | |
---|
24 | const char rtems_test_name[] = "SPCONFIG 2"; |
---|
25 | |
---|
26 | static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E'); |
---|
27 | |
---|
28 | static void test_barrier(void) |
---|
29 | { |
---|
30 | rtems_status_code sc; |
---|
31 | rtems_id id; |
---|
32 | |
---|
33 | sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id); |
---|
34 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
35 | } |
---|
36 | |
---|
37 | static void test_message_queue(void) |
---|
38 | { |
---|
39 | rtems_status_code sc; |
---|
40 | rtems_id id; |
---|
41 | |
---|
42 | sc = rtems_message_queue_create( |
---|
43 | name, |
---|
44 | 1, |
---|
45 | 1, |
---|
46 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
47 | &id |
---|
48 | ); |
---|
49 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
50 | |
---|
51 | sc = rtems_message_queue_delete(0); |
---|
52 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
53 | |
---|
54 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0); |
---|
55 | sc = rtems_message_queue_delete(id); |
---|
56 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
57 | } |
---|
58 | |
---|
59 | static void test_partition(void) |
---|
60 | { |
---|
61 | rtems_status_code sc; |
---|
62 | rtems_id id; |
---|
63 | long buf[32]; |
---|
64 | |
---|
65 | sc = rtems_partition_create( |
---|
66 | name, |
---|
67 | buf, |
---|
68 | sizeof(buf), |
---|
69 | sizeof(buf), |
---|
70 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
71 | &id |
---|
72 | ); |
---|
73 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
74 | |
---|
75 | sc = rtems_partition_delete(0); |
---|
76 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
77 | |
---|
78 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0); |
---|
79 | sc = rtems_partition_delete(id); |
---|
80 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
81 | } |
---|
82 | |
---|
83 | static void test_rate_monotonic(void) |
---|
84 | { |
---|
85 | rtems_status_code sc; |
---|
86 | rtems_id id; |
---|
87 | |
---|
88 | sc = rtems_rate_monotonic_create(name, &id); |
---|
89 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
90 | |
---|
91 | sc = rtems_rate_monotonic_delete(0); |
---|
92 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
93 | |
---|
94 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0); |
---|
95 | sc = rtems_rate_monotonic_delete(id); |
---|
96 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
97 | } |
---|
98 | |
---|
99 | static void test_region(void) |
---|
100 | { |
---|
101 | rtems_status_code sc; |
---|
102 | rtems_id id; |
---|
103 | long buf[32]; |
---|
104 | |
---|
105 | sc = rtems_region_create( |
---|
106 | name, |
---|
107 | buf, |
---|
108 | sizeof(buf), |
---|
109 | 1, |
---|
110 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
111 | &id |
---|
112 | ); |
---|
113 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
114 | |
---|
115 | sc = rtems_region_delete(0); |
---|
116 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
117 | |
---|
118 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0); |
---|
119 | sc = rtems_region_delete(id); |
---|
120 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
121 | } |
---|
122 | |
---|
123 | static void test_semaphore(void) |
---|
124 | { |
---|
125 | rtems_status_code sc; |
---|
126 | rtems_id id; |
---|
127 | |
---|
128 | sc = rtems_semaphore_create( |
---|
129 | name, |
---|
130 | 0, |
---|
131 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
132 | 0, |
---|
133 | &id |
---|
134 | ); |
---|
135 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
136 | |
---|
137 | sc = rtems_semaphore_delete(0); |
---|
138 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
139 | |
---|
140 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0); |
---|
141 | sc = rtems_semaphore_delete(id); |
---|
142 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
143 | } |
---|
144 | |
---|
145 | static void test_task(void) |
---|
146 | { |
---|
147 | rtems_status_code sc; |
---|
148 | rtems_id id; |
---|
149 | |
---|
150 | sc = rtems_task_create( |
---|
151 | name, |
---|
152 | 1, |
---|
153 | RTEMS_MINIMUM_STACK_SIZE, |
---|
154 | RTEMS_DEFAULT_MODES, |
---|
155 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
156 | &id |
---|
157 | ); |
---|
158 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
159 | |
---|
160 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0); |
---|
161 | sc = rtems_task_delete(id); |
---|
162 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
163 | } |
---|
164 | |
---|
165 | static void test_timer(void) |
---|
166 | { |
---|
167 | rtems_status_code sc; |
---|
168 | rtems_id id; |
---|
169 | |
---|
170 | sc = rtems_timer_create(name, &id); |
---|
171 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
172 | |
---|
173 | sc = rtems_timer_delete(0); |
---|
174 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
175 | |
---|
176 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0); |
---|
177 | sc = rtems_timer_delete(id); |
---|
178 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
179 | } |
---|
180 | |
---|
181 | static void test_user_extensions(void) |
---|
182 | { |
---|
183 | rtems_status_code sc; |
---|
184 | rtems_id id; |
---|
185 | rtems_extensions_table table; |
---|
186 | |
---|
187 | memset(&table, 0, sizeof(table)); |
---|
188 | sc = rtems_extension_create(name, &table, &id); |
---|
189 | rtems_test_assert(sc == RTEMS_TOO_MANY); |
---|
190 | |
---|
191 | sc = rtems_extension_delete(0); |
---|
192 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
193 | |
---|
194 | id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_EXTENSIONS, 1, 0); |
---|
195 | sc = rtems_extension_delete(id); |
---|
196 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
197 | } |
---|
198 | |
---|
199 | static void test_id_to_name(rtems_id api, rtems_id cls, rtems_id idx, bool *found) |
---|
200 | { |
---|
201 | rtems_status_code sc; |
---|
202 | rtems_id id; |
---|
203 | rtems_name name_of_id; |
---|
204 | |
---|
205 | id = rtems_build_id(api, cls, 1, idx); |
---|
206 | sc = rtems_object_get_classic_name(id, &name_of_id); |
---|
207 | |
---|
208 | if (sc == RTEMS_SUCCESSFUL) { |
---|
209 | if (name_of_id == rtems_build_name('U', 'I', '1', ' ')) { |
---|
210 | rtems_test_assert(id == rtems_task_self()); |
---|
211 | rtems_test_assert(!found[0]); |
---|
212 | found[0] = true; |
---|
213 | } else { |
---|
214 | rtems_test_assert(name_of_id == rtems_build_name('I', 'D', 'L', 'E')); |
---|
215 | rtems_test_assert(!found[1]); |
---|
216 | found[1] = true; |
---|
217 | } |
---|
218 | } else { |
---|
219 | rtems_test_assert(sc == RTEMS_INVALID_ID); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | static void test_some_id_to_name(void) |
---|
224 | { |
---|
225 | rtems_id api; |
---|
226 | bool found[2]; |
---|
227 | |
---|
228 | found[0] = false; |
---|
229 | found[1] = false; |
---|
230 | |
---|
231 | for (api = 0; api < 8; ++api) { |
---|
232 | rtems_id cls; |
---|
233 | |
---|
234 | for (cls = 0; cls < 32; ++cls) { |
---|
235 | test_id_to_name(api, cls, 0, found); |
---|
236 | test_id_to_name(api, cls, 1, found); |
---|
237 | test_id_to_name(api, cls, 2, found); |
---|
238 | test_id_to_name(api, cls, 65534, found); |
---|
239 | test_id_to_name(api, cls, 65535, found); |
---|
240 | } |
---|
241 | } |
---|
242 | |
---|
243 | rtems_test_assert(found[0]); |
---|
244 | rtems_test_assert(found[1]); |
---|
245 | } |
---|
246 | |
---|
247 | static void Init(rtems_task_argument arg) |
---|
248 | { |
---|
249 | rtems_print_printer_printk(&rtems_test_printer); |
---|
250 | TEST_BEGIN(); |
---|
251 | test_barrier(); |
---|
252 | test_message_queue(); |
---|
253 | test_partition(); |
---|
254 | test_rate_monotonic(); |
---|
255 | test_region(); |
---|
256 | test_semaphore(); |
---|
257 | test_task(); |
---|
258 | test_timer(); |
---|
259 | test_user_extensions(); |
---|
260 | test_some_id_to_name(); |
---|
261 | TEST_END(); |
---|
262 | rtems_test_exit(0); |
---|
263 | } |
---|
264 | |
---|
265 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
266 | |
---|
267 | #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM |
---|
268 | |
---|
269 | #define CONFIGURE_DISABLE_NEWLIB_REENTRANCY |
---|
270 | |
---|
271 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
272 | |
---|
273 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
274 | |
---|
275 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
276 | |
---|
277 | #define CONFIGURE_INIT |
---|
278 | |
---|
279 | #include <rtems/confdefs.h> |
---|