RTEMS 6.1-rc6
Loading...
Searching...
No Matches
ts-fatal-sysinit.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * Copyright (C) 2021 embedded brains GmbH & Co. KG
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <rtems.h>
39#include <rtems/bspIo.h>
40#include <rtems/sysinit.h>
41#include <rtems/test-info.h>
42#include <rtems/testopts.h>
43#include <rtems/score/atomic.h>
44
45#include <rtems/test.h>
46
47#include "tx-support.h"
48
49static char buffer[ 512 ];
50
51static const T_action actions[] = {
52 T_report_hash_sha256
53};
54
55static const T_config test_config = {
56 .name = rtems_test_name,
57 .buf = buffer,
58 .buf_size = sizeof( buffer ),
59 .putchar = rtems_put_char,
60 .verbosity = RTEMS_TEST_VERBOSITY,
61#if defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER)
62 .now = T_now_clock,
63#else
64 .now = T_now_tick,
65#endif
66 .allocate = T_memory_allocate,
67 .deallocate = T_memory_deallocate,
68 .action_count = T_ARRAY_SIZE( actions ),
69 .actions = actions
70};
71
72static Atomic_Uint counter;
73
74static void TestSuiteFatalExtension(
75 rtems_fatal_source source,
76 bool always_set_to_false,
78)
79{
80 rtems_fatal_code exit_code;
81
82 (void) always_set_to_false;
83
84 if ( source == RTEMS_FATAL_SOURCE_EXIT ) {
85 return;
86 }
87
88 if ( _Atomic_Fetch_add_uint( &counter, 1, ATOMIC_ORDER_RELAXED ) != 0 ) {
89 return;
90 }
91
92 T_make_runner();
93 FATAL_SYSINIT_RUN( source, code );
94
95 if ( T_run_finalize() ) {
97 exit_code = 0;
98 } else {
99 exit_code = 1;
100 }
101
102#if defined(FATAL_SYSINIT_EXIT)
103 FATAL_SYSINIT_EXIT( exit_code );
104#else
105 rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, exit_code );
106#endif
107}
108
109static void TestRunInitialize( void )
110{
111 rtems_test_begin( rtems_test_name, TEST_STATE );
112 T_run_initialize( &test_config );
113}
114
116 TestRunInitialize,
117 RTEMS_SYSINIT_BSP_EARLY,
118 RTEMS_SYSINIT_ORDER_FIRST
119);
120
121#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0
122
123#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
124
125#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
126
127#ifdef FATAL_SYSINIT_INITIAL_EXTENSION
128#define OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION FATAL_SYSINIT_INITIAL_EXTENSION,
129#else
130#define OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION
131#endif
132
133#define CONFIGURE_INITIAL_EXTENSIONS \
134 OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION \
135 { .fatal = FatalInitialExtension }, \
136 { .fatal = TestSuiteFatalExtension }
137
138#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
139
140#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE)
141
142#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
143
144#if !defined(CONFIGURE_IDLE_TASK_BODY)
145
146#define CONFIGURE_IDLE_TASK_BODY IdleBody
147
148void *IdleBody( uintptr_t ignored )
149{
150 (void) ignored;
151
152 rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, 1 );
153}
154
155#endif /* CONFIGURE_IDLE_TASK_BODY */
156
157#endif /* CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION */
158
159#define CONFIGURE_INIT
160
161#include <rtems/confdefs.h>
This header file provides the kernel character input/output support API.
This header file evaluates the application configuration options defined by the application.
Internal_errors_t rtems_fatal_code
This integer type represents system termination codes.
Definition: extension.h:162
void rtems_put_char(int c, void *unused)
Puts the character using rtems_putc()
Definition: rtems_put_char.c:42
#define RTEMS_SYSINIT_ITEM(handler, module, order)
Creates the system initialization item associated with the handler, module, and order.
Definition: sysinit.h:204
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:63
@ RTEMS_FATAL_SOURCE_EXIT
Fatal source of exit().
Definition: interr.h:100
const char rtems_test_name[]
Each test must define a test name string.
Definition: init.c:6899
int rtems_test_begin(const char *name, const RTEMS_TEST_STATE state)
Prints a begin of test message using printf().
Definition: testbeginend.c:56
int rtems_test_end(const char *name)
Prints an end of test message using printf().
Definition: testbeginend.c:93
This header file provides the interfaces of the Atomic Operations.
This header file defines the RTEMS Classic API.
Definition: test.h:2295
Definition: inftrees.h:24
This header file provides the API of the System Initialization Support.
This header file provides interfaces of the RTEMS Test Support.
This header file provides interfaces of the RTEMS Test Framework.
This header file provides the support functions for the validation test cases.