source: rtems/testsuites/libtests/exit02/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.9 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#include <stdlib.h>
20
21/* Use assert() not rtems_test_assert() since it uses exit() */
22#include <assert.h>
23
24#include <rtems.h>
25#include <rtems/test.h>
26
27const char rtems_test_name[] = "EXIT 2";
28
29#define EXIT_STATUS 123
30
31static void atexit_not_reached(void)
32{
33  assert(0);
34}
35
36static void fatal_extension(
37  rtems_fatal_source source,
38  bool is_internal,
39  rtems_fatal_code error
40)
41{
42  if (
43    source == RTEMS_FATAL_SOURCE_EXIT
44      && !is_internal
45      && error == EXIT_STATUS
46  ) {
47    rtems_test_endk();
48  }
49}
50
51static void exit_task(rtems_task_argument arg)
52{
53  int rv;
54
55  rv = atexit(atexit_not_reached);
56  assert(rv == 0);
57
58  _Exit(EXIT_STATUS);
59}
60
61static void Init(rtems_task_argument arg)
62{
63  rtems_status_code sc;
64  rtems_id id;
65
66  rtems_test_begink();
67
68  sc = rtems_task_create(
69    rtems_build_name('E', 'X', 'I', 'T'),
70    RTEMS_MINIMUM_PRIORITY,
71    RTEMS_MINIMUM_STACK_SIZE,
72    RTEMS_DEFAULT_MODES,
73    RTEMS_DEFAULT_ATTRIBUTES,
74    &id
75  );
76  assert(sc == RTEMS_SUCCESSFUL);
77
78  sc = rtems_task_start(id, exit_task, 0);
79  assert(sc == RTEMS_SUCCESSFUL);
80
81  sc = rtems_task_delete(RTEMS_SELF);
82  assert(sc == RTEMS_SUCCESSFUL);
83}
84
85#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
86#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
87
88#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
89
90#define CONFIGURE_INITIAL_EXTENSIONS \
91  { .fatal = fatal_extension }, \
92  RTEMS_TEST_INITIAL_EXTENSION
93
94#define CONFIGURE_MAXIMUM_TASKS 2
95
96#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
97
98#define CONFIGURE_INIT
99
100#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.