source: rtems/testsuites/validation/ts-fatal-sysinit.h @ 1ab93ba

Last change on this file since 1ab93ba was 1ab93ba, checked in by Sebastian Huber <sebastian.huber@…>, on 09/28/22 at 10:22:33

score: INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED

Add the INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED fatal error in case the
creation of an idle thread fails. This may happen due to a failing create
extension provided by the application.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief This header file provides a configurable validation test suite runner
7 *   and application configuration for fatal error tests which occur during
8 *   system initialization.
9 */
10
11/*
12 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <rtems.h>
37#include <rtems/bspIo.h>
38#include <rtems/sysinit.h>
39#include <rtems/test-info.h>
40#include <rtems/testopts.h>
41#include <rtems/score/atomic.h>
42
43#include <rtems/test.h>
44
45#include "tx-support.h"
46
47static char buffer[ 512 ];
48
49static const T_action actions[] = {
50  T_report_hash_sha256
51};
52
53static const T_config test_config = {
54  .name = rtems_test_name,
55  .buf = buffer,
56  .buf_size = sizeof( buffer ),
57  .putchar = rtems_put_char,
58  .verbosity = RTEMS_TEST_VERBOSITY,
59#if defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER)
60  .now = T_now_clock,
61#else
62  .now = T_now_tick,
63#endif
64  .allocate = T_memory_allocate,
65  .deallocate = T_memory_deallocate,
66  .action_count = T_ARRAY_SIZE( actions ),
67  .actions = actions
68};
69
70static Atomic_Uint counter;
71
72static void TestSuiteFatalExtension(
73  rtems_fatal_source source,
74  bool always_set_to_false,
75  rtems_fatal_code code
76)
77{
78  rtems_fatal_code exit_code;
79
80  (void) always_set_to_false;
81
82  if ( source == RTEMS_FATAL_SOURCE_EXIT ) {
83    return;
84  }
85
86  if ( _Atomic_Fetch_add_uint( &counter, 1, ATOMIC_ORDER_RELAXED ) != 0 ) {
87    return;
88  }
89
90  T_make_runner();
91  FATAL_SYSINIT_RUN( source, code );
92
93  if ( T_run_finalize() ) {
94    rtems_test_end( rtems_test_name );
95    exit_code = 0;
96  } else {
97    exit_code = 1;
98  }
99
100#if defined(FATAL_SYSINIT_EXIT)
101  FATAL_SYSINIT_EXIT( exit_code );
102#else
103  rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, exit_code );
104#endif
105}
106
107static void TestRunInitialize( void )
108{
109  rtems_test_begin( rtems_test_name, TEST_STATE );
110  T_run_initialize( &test_config );
111}
112
113RTEMS_SYSINIT_ITEM(
114  TestRunInitialize,
115  RTEMS_SYSINIT_BSP_EARLY,
116  RTEMS_SYSINIT_ORDER_FIRST
117);
118
119#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0
120
121#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
122
123#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
124
125#ifdef FATAL_SYSINIT_INITIAL_EXTENSION
126#define OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION FATAL_SYSINIT_INITIAL_EXTENSION,
127#else
128#define OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION
129#endif
130
131#define CONFIGURE_INITIAL_EXTENSIONS \
132  OPTIONAL_FATAL_SYSINIT_INITIAL_EXTENSION \
133  { .fatal = FatalInitialExtension }, \
134  { .fatal = TestSuiteFatalExtension }
135
136#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE)
137
138#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
139
140#if !defined(CONFIGURE_IDLE_TASK_BODY)
141
142#define CONFIGURE_IDLE_TASK_BODY IdleBody
143
144void *IdleBody( uintptr_t ignored )
145{
146  (void) ignored;
147
148  rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, 1 );
149}
150
151#endif /* CONFIGURE_IDLE_TASK_BODY */
152
153#endif /* CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION */
154
155#define CONFIGURE_INIT
156
157#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.