source: rtems/testsuites/sptests/spglobalcon02/init.c @ 8b2d5b8

5
Last change on this file since 8b2d5b8 was 8b2d5b8, checked in by Sebastian Huber <sebastian.huber@…>, on 02/28/18 at 12:02:55

spglobalcon02: New test

Update #3319.

  • Property mode set to 100644
File size: 1.9 KB
Line 
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 <stdlib.h>
20
21#include <tmacros.h>
22
23const char rtems_test_name[] = "SPGLOBALCON 2";
24
25static int i;
26
27static __attribute__((__constructor__(1000))) void c0(void)
28{
29  rtems_test_assert(i == 0);
30  ++i;
31}
32
33static __attribute__((__constructor__(1001))) void c1(void)
34{
35  rtems_test_assert(i == 1);
36  ++i;
37}
38
39static __attribute__((__constructor__(1002))) void c2(void)
40{
41  rtems_test_assert(i == 2);
42  ++i;
43}
44
45static __attribute__((__constructor__)) void c(void)
46{
47  rtems_test_assert(i == 3);
48  ++i;
49}
50
51static __attribute__((__destructor__(1000))) void d0(void)
52{
53  rtems_test_assert(i == 8);
54  ++i;
55}
56
57static __attribute__((__destructor__(1001))) void d1(void)
58{
59  rtems_test_assert(i == 7);
60  ++i;
61}
62
63static __attribute__((__destructor__(1002))) void d2(void)
64{
65  rtems_test_assert(i == 6);
66  ++i;
67}
68
69static __attribute__((__destructor__)) void d(void)
70{
71  rtems_test_assert(i == 5);
72  ++i;
73}
74
75static void Init(rtems_task_argument arg)
76{
77  TEST_BEGIN();
78  rtems_test_assert(i == 4);
79  ++i;
80  exit(0);
81}
82
83static void fatal_extension(
84  rtems_fatal_source source,
85  bool always_set_to_false,
86  rtems_fatal_code error
87)
88{
89  if (
90    source == RTEMS_FATAL_SOURCE_EXIT
91      && !always_set_to_false
92      && error == 0
93      && i == 9
94  ) {
95    TEST_END();
96  }
97}
98
99#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
100#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
101
102#define CONFIGURE_MAXIMUM_TASKS 1
103
104#define CONFIGURE_INITIAL_EXTENSIONS \
105  { .fatal = fatal_extension }, \
106  RTEMS_TEST_INITIAL_EXTENSION
107
108#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
109
110#define CONFIGURE_INIT
111
112#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.