source: rtems/testsuites/libtests/exit01/init.c @ acc9d064

5
Last change on this file since acc9d064 was acc9d064, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:10

tests: Remove obsolete TESTS_USE_PRINTK

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
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.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#define TEST_INIT
20
21#include "tmacros.h"
22
23#include <stdlib.h>
24
25/* Use assert() not rtems_test_assert() since it uses exit() */
26#include <assert.h>
27
28#include <rtems.h>
29
30const char rtems_test_name[] = "EXIT 1";
31
32#define EXIT_STATUS 123
33
34static int counter;
35
36static void atexit_0(void)
37{
38  assert(counter == 0);
39  ++counter;
40}
41
42static void atexit_1(void)
43{
44  assert(counter == 1);
45  ++counter;
46}
47
48static void atexit_2(void)
49{
50  assert(counter == 2);
51  ++counter;
52}
53
54static void fatal_extension(
55  rtems_fatal_source source,
56  bool always_set_to_false,
57  rtems_fatal_code error
58)
59{
60  if (
61    source == RTEMS_FATAL_SOURCE_EXIT
62      && !always_set_to_false
63      && error == EXIT_STATUS
64      && counter == 3
65  ) {
66    TEST_END();
67  }
68}
69
70static void exit_task(rtems_task_argument arg)
71{
72  int rv;
73
74  rv = atexit(atexit_2);
75  assert(rv == 0);
76
77  rv = atexit(atexit_1);
78  assert(rv == 0);
79
80  rv = atexit(atexit_0);
81  assert(rv == 0);
82
83  exit(EXIT_STATUS);
84}
85
86static void Init(rtems_task_argument arg)
87{
88  rtems_status_code sc;
89  rtems_id id;
90
91  TEST_BEGIN();
92
93  sc = rtems_task_create(
94    rtems_build_name('E', 'X', 'I', 'T'),
95    RTEMS_MINIMUM_PRIORITY,
96    RTEMS_MINIMUM_STACK_SIZE,
97    RTEMS_DEFAULT_MODES,
98    RTEMS_DEFAULT_ATTRIBUTES,
99    &id
100  );
101  assert(sc == RTEMS_SUCCESSFUL);
102
103  sc = rtems_task_start(id, exit_task, 0);
104  assert(sc == RTEMS_SUCCESSFUL);
105
106  sc = rtems_task_delete(RTEMS_SELF);
107  assert(sc == RTEMS_SUCCESSFUL);
108}
109
110#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
111#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
112
113#define CONFIGURE_INITIAL_EXTENSIONS \
114  { .fatal = fatal_extension }, \
115  RTEMS_TEST_INITIAL_EXTENSION
116
117#define CONFIGURE_MAXIMUM_TASKS 2
118
119#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
120
121#define CONFIGURE_INIT
122
123#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.