source: rtems/testsuites/sptests/spsysinit01/init.c @ 04436ae

Last change on this file since 04436ae was 04436ae, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 10, 2015 at 12:46:07 PM

Optional POSIX Signals initialization

Update #2408.

  • Property mode set to 100644
File size: 9.4 KB
Line 
1/*
2 * Copyright (c) 2015 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 <assert.h>
20#include <string.h>
21#include <stdlib.h>
22
23#include <rtems.h>
24#include <rtems/libio_.h>
25#include <rtems/sysinit.h>
26#include <rtems/test.h>
27
28#include <rtems/extensionimpl.h>
29#ifdef RTEMS_POSIX_API
30#include <rtems/posix/psignalimpl.h>
31#endif /* RTEMS_POSIX_API */
32#include <rtems/rtems/barrierimpl.h>
33#include <rtems/rtems/dpmemimpl.h>
34#include <rtems/rtems/messageimpl.h>
35#include <rtems/rtems/partimpl.h>
36#include <rtems/rtems/ratemonimpl.h>
37#include <rtems/rtems/regionimpl.h>
38#include <rtems/rtems/semimpl.h>
39#include <rtems/rtems/tasksimpl.h>
40#include <rtems/rtems/timerimpl.h>
41#include <rtems/score/apimutex.h>
42#include <rtems/score/sysstate.h>
43#include <rtems/score/userextimpl.h>
44#include <rtems/score/wkspace.h>
45
46const char rtems_test_name[] = "SPSYSINIT 1";
47
48typedef enum {
49  BSP_WORK_AREAS_PRE,
50  BSP_WORK_AREAS_POST,
51  BSP_START_PRE,
52  BSP_START_POST,
53  INITIAL_EXTENSIONS_PRE,
54  INITIAL_EXTENSIONS_POST,
55  DATA_STRUCTURES_PRE,
56  DATA_STRUCTURES_POST,
57  USER_EXTENSIONS_PRE,
58  USER_EXTENSIONS_POST,
59  CLASSIC_TASKS_PRE,
60  CLASSIC_TASKS_POST,
61  CLASSIC_TIMER_PRE,
62  CLASSIC_TIMER_POST,
63  CLASSIC_SIGNAL_PRE,
64  CLASSIC_SIGNAL_POST,
65  CLASSIC_EVENT_PRE,
66  CLASSIC_EVENT_POST,
67  CLASSIC_MESSAGE_QUEUE_PRE,
68  CLASSIC_MESSAGE_QUEUE_POST,
69  CLASSIC_SEMAPHORE_PRE,
70  CLASSIC_SEMAPHORE_POST,
71  CLASSIC_PARTITION_PRE,
72  CLASSIC_PARTITION_POST,
73  CLASSIC_REGION_PRE,
74  CLASSIC_REGION_POST,
75  CLASSIC_DUAL_PORTED_MEMORY_PRE,
76  CLASSIC_DUAL_PORTED_MEMORY_POST,
77  CLASSIC_RATE_MONOTONIC_PRE,
78  CLASSIC_RATE_MONOTONIC_POST,
79  CLASSIC_BARRIER_PRE,
80  CLASSIC_BARRIER_POST,
81#ifdef RTEMS_POSIX_API
82  POSIX_SIGNALS_PRE,
83  POSIX_SIGNALS_POST,
84#endif /* RTEMS_POSIX_API */
85  IDLE_THREADS_PRE,
86  IDLE_THREADS_POST,
87  BSP_LIBC_PRE,
88  BSP_LIBC_POST,
89  BEFORE_DRIVERS_PRE,
90  BEFORE_DRIVERS_POST,
91  BSP_PRE_DRIVERS_PRE,
92  BSP_PRE_DRIVERS_POST,
93  DEVICE_DRIVERS_PRE,
94  DEVICE_DRIVERS_POST,
95  BSP_POST_DRIVERS_PRE,
96  BSP_POST_DRIVERS_POST,
97  INIT_TASK,
98  DONE
99} init_step;
100
101#define FIRST(x) \
102  static void x##_first(void); \
103  RTEMS_SYSINIT_ITEM( \
104    x##_first, \
105    x, \
106    RTEMS_SYSINIT_ORDER_FIRST \
107  ); \
108  static void x##_first(void)
109
110#define LAST(x) \
111  static void x##_last(void); \
112  RTEMS_SYSINIT_ITEM( \
113    x##_last, \
114    x, \
115    RTEMS_SYSINIT_ORDER_LAST \
116  ); \
117  static void x##_last(void)
118
119static init_step step;
120
121static void next_step(init_step expected)
122{
123  assert(step == expected);
124  step = expected + 1;
125}
126
127FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS)
128{
129  rtems_test_begink();
130  assert(_Workspace_Area.area_begin == 0);
131  next_step(BSP_WORK_AREAS_PRE);
132}
133
134LAST(RTEMS_SYSINIT_BSP_WORK_AREAS)
135{
136  assert(_Workspace_Area.area_begin != 0);
137  next_step(BSP_WORK_AREAS_POST);
138}
139
140FIRST(RTEMS_SYSINIT_BSP_START)
141{
142  /*
143   * Since the work performed here is BSP-specific, there is no way to test pre
144   * and post conditions.
145   */
146  next_step(BSP_START_PRE);
147}
148
149LAST(RTEMS_SYSINIT_BSP_START)
150{
151  next_step(BSP_START_POST);
152}
153
154FIRST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
155{
156  assert(_Chain_Is_empty(&_User_extensions_Switches_list));
157  next_step(INITIAL_EXTENSIONS_PRE);
158}
159
160LAST(RTEMS_SYSINIT_INITIAL_EXTENSIONS)
161{
162  assert(!_Chain_Is_empty(&_User_extensions_Switches_list));
163  next_step(INITIAL_EXTENSIONS_POST);
164}
165
166FIRST(RTEMS_SYSINIT_DATA_STRUCTURES)
167{
168  assert(_RTEMS_Allocator_Mutex == NULL);
169  next_step(DATA_STRUCTURES_PRE);
170}
171
172LAST(RTEMS_SYSINIT_DATA_STRUCTURES)
173{
174  assert(_RTEMS_Allocator_Mutex != NULL);
175  next_step(DATA_STRUCTURES_POST);
176}
177
178FIRST(RTEMS_SYSINIT_USER_EXTENSIONS)
179{
180  assert(_Extension_Information.maximum == 0);
181  next_step(USER_EXTENSIONS_PRE);
182}
183
184LAST(RTEMS_SYSINIT_USER_EXTENSIONS)
185{
186  assert(_Extension_Information.maximum != 0);
187  next_step(USER_EXTENSIONS_POST);
188}
189
190FIRST(RTEMS_SYSINIT_CLASSIC_TASKS)
191{
192  assert(_RTEMS_tasks_Information.Objects.maximum == 0);
193  next_step(CLASSIC_TASKS_PRE);
194}
195
196LAST(RTEMS_SYSINIT_CLASSIC_TASKS)
197{
198  assert(_RTEMS_tasks_Information.Objects.maximum != 0);
199  next_step(CLASSIC_TASKS_POST);
200}
201
202FIRST(RTEMS_SYSINIT_CLASSIC_TIMER)
203{
204  assert(_Timer_Information.maximum == 0);
205  next_step(CLASSIC_TIMER_PRE);
206}
207
208LAST(RTEMS_SYSINIT_CLASSIC_TIMER)
209{
210  assert(_Timer_Information.maximum != 0);
211  next_step(CLASSIC_TIMER_POST);
212}
213
214FIRST(RTEMS_SYSINIT_CLASSIC_SIGNAL)
215{
216  /* There is nothing to do in case RTEMS_MULTIPROCESSING is not defined */
217  next_step(CLASSIC_SIGNAL_PRE);
218}
219
220LAST(RTEMS_SYSINIT_CLASSIC_SIGNAL)
221{
222  next_step(CLASSIC_SIGNAL_POST);
223}
224
225FIRST(RTEMS_SYSINIT_CLASSIC_EVENT)
226{
227  /* There is nothing to do in case RTEMS_MULTIPROCESSING is not defined */
228  next_step(CLASSIC_EVENT_PRE);
229}
230
231LAST(RTEMS_SYSINIT_CLASSIC_EVENT)
232{
233  next_step(CLASSIC_EVENT_POST);
234}
235
236FIRST(RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE)
237{
238  assert(_Message_queue_Information.maximum == 0);
239  next_step(CLASSIC_MESSAGE_QUEUE_PRE);
240}
241
242LAST(RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE)
243{
244  assert(_Message_queue_Information.maximum != 0);
245  next_step(CLASSIC_MESSAGE_QUEUE_POST);
246}
247
248FIRST(RTEMS_SYSINIT_CLASSIC_SEMAPHORE)
249{
250  assert(_Semaphore_Information.maximum == 0);
251  next_step(CLASSIC_SEMAPHORE_PRE);
252}
253
254LAST(RTEMS_SYSINIT_CLASSIC_SEMAPHORE)
255{
256  assert(_Semaphore_Information.maximum != 0);
257  next_step(CLASSIC_SEMAPHORE_POST);
258}
259
260FIRST(RTEMS_SYSINIT_CLASSIC_PARTITION)
261{
262  assert(_Partition_Information.maximum == 0);
263  next_step(CLASSIC_PARTITION_PRE);
264}
265
266LAST(RTEMS_SYSINIT_CLASSIC_PARTITION)
267{
268  assert(_Partition_Information.maximum != 0);
269  next_step(CLASSIC_PARTITION_POST);
270}
271
272FIRST(RTEMS_SYSINIT_CLASSIC_REGION)
273{
274  assert(_Region_Information.maximum == 0);
275  next_step(CLASSIC_REGION_PRE);
276}
277
278LAST(RTEMS_SYSINIT_CLASSIC_REGION)
279{
280  assert(_Region_Information.maximum != 0);
281  next_step(CLASSIC_REGION_POST);
282}
283
284FIRST(RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY)
285{
286  assert(_Dual_ported_memory_Information.maximum == 0);
287  next_step(CLASSIC_DUAL_PORTED_MEMORY_PRE);
288}
289
290LAST(RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY)
291{
292  assert(_Dual_ported_memory_Information.maximum != 0);
293  next_step(CLASSIC_DUAL_PORTED_MEMORY_POST);
294}
295
296FIRST(RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC)
297{
298  assert(_Rate_monotonic_Information.maximum == 0);
299  next_step(CLASSIC_RATE_MONOTONIC_PRE);
300}
301
302LAST(RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC)
303{
304  assert(_Rate_monotonic_Information.maximum != 0);
305  next_step(CLASSIC_RATE_MONOTONIC_POST);
306}
307
308FIRST(RTEMS_SYSINIT_CLASSIC_BARRIER)
309{
310  assert(_Barrier_Information.maximum == 0);
311  next_step(CLASSIC_BARRIER_PRE);
312}
313
314LAST(RTEMS_SYSINIT_CLASSIC_BARRIER)
315{
316  assert(_Barrier_Information.maximum != 0);
317  next_step(CLASSIC_BARRIER_POST);
318}
319
320#ifdef RTEMS_POSIX_API
321
322FIRST(RTEMS_SYSINIT_POSIX_SIGNALS)
323{
324  assert(
325    memcmp(
326      &_POSIX_signals_Vectors,
327      _POSIX_signals_Default_vectors,
328      sizeof(_POSIX_signals_Vectors)
329    ) != 0
330  );
331  next_step(POSIX_SIGNALS_PRE);
332}
333
334LAST(RTEMS_SYSINIT_POSIX_SIGNALS)
335{
336  assert(
337    memcmp(
338      &_POSIX_signals_Vectors,
339      _POSIX_signals_Default_vectors,
340      sizeof(_POSIX_signals_Vectors)
341    ) == 0
342  );
343  next_step(POSIX_SIGNALS_POST);
344}
345
346#endif /* RTEMS_POSIX_API */
347
348FIRST(RTEMS_SYSINIT_IDLE_THREADS)
349{
350  assert(_System_state_Is_before_initialization(_System_state_Get()));
351  next_step(IDLE_THREADS_PRE);
352}
353
354LAST(RTEMS_SYSINIT_IDLE_THREADS)
355{
356  assert(_System_state_Is_before_multitasking(_System_state_Get()));
357  next_step(IDLE_THREADS_POST);
358}
359
360FIRST(RTEMS_SYSINIT_BSP_LIBC)
361{
362  assert(rtems_libio_semaphore == 0);
363  next_step(BSP_LIBC_PRE);
364}
365
366LAST(RTEMS_SYSINIT_BSP_LIBC)
367{
368  assert(rtems_libio_semaphore != 0);
369  next_step(BSP_LIBC_POST);
370}
371
372FIRST(RTEMS_SYSINIT_BEFORE_DRIVERS)
373{
374  /* Omit test of build configuration specific pre and post conditions */
375  next_step(BEFORE_DRIVERS_PRE);
376}
377
378LAST(RTEMS_SYSINIT_BEFORE_DRIVERS)
379{
380  next_step(BEFORE_DRIVERS_POST);
381}
382
383FIRST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
384{
385  /*
386   * Since the work performed here is BSP-specific, there is no way to test pre
387   * and post conditions.
388   */
389  next_step(BSP_PRE_DRIVERS_PRE);
390}
391
392LAST(RTEMS_SYSINIT_BSP_PRE_DRIVERS)
393{
394  next_step(BSP_PRE_DRIVERS_POST);
395}
396
397FIRST(RTEMS_SYSINIT_DEVICE_DRIVERS)
398{
399  assert(!_IO_All_drivers_initialized);
400  next_step(DEVICE_DRIVERS_PRE);
401}
402
403LAST(RTEMS_SYSINIT_DEVICE_DRIVERS)
404{
405  assert(_IO_All_drivers_initialized);
406  next_step(DEVICE_DRIVERS_POST);
407}
408
409FIRST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
410{
411  assert(rtems_libio_iop_freelist != NULL);
412  next_step(BSP_POST_DRIVERS_PRE);
413}
414
415LAST(RTEMS_SYSINIT_BSP_POST_DRIVERS)
416{
417  assert(rtems_libio_iop_freelist == NULL);
418  next_step(BSP_POST_DRIVERS_POST);
419}
420
421static void Init(rtems_task_argument arg)
422{
423  next_step(INIT_TASK);
424  rtems_test_endk();
425  exit(0);
426}
427
428#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
429#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
430
431#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
432
433#define CONFIGURE_MAXIMUM_BARRIERS 1
434
435#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
436
437#define CONFIGURE_MAXIMUM_PARTITIONS 1
438
439#define CONFIGURE_MAXIMUM_PERIODS 1
440
441#define CONFIGURE_MAXIMUM_PORTS 1
442
443#define CONFIGURE_MAXIMUM_REGIONS 1
444
445#define CONFIGURE_MAXIMUM_SEMAPHORES 1
446
447#define CONFIGURE_MAXIMUM_TASKS 1
448
449#define CONFIGURE_MAXIMUM_TIMERS 1
450
451#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
452
453#define CONFIGURE_STACK_CHECKER_ENABLED
454
455#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
456
457#define CONFIGURE_INIT
458
459#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.