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

4.115
Last change on this file since dfd1508 was dfd1508, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/13 at 12:30:52

libtests/exit02: New test

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