summaryrefslogtreecommitdiff
path: root/testsuites/validation/ts-space-profile.c
blob: 7b35042ad235a898ea04d6296d54c5ec468920c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @ingroup RTEMSTestSuiteTestsuitesValidationProfile
 */

/*
 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file is part of the RTEMS quality process and was automatically
 * generated.  If you find something that needs to be fixed or
 * worded better please post a report or patch to an RTEMS mailing list
 * or raise a bug report:
 *
 * https://www.rtems.org/bugs.html
 *
 * For information on updating and regenerating please refer to the How-To
 * section in the Software Requirements Engineering chapter of the
 * RTEMS Software Engineering manual.  The manual is provided as a part of
 * a release.  For development sources please refer to the online
 * documentation at:
 *
 * https://docs.rtems.org
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems.h>
#include <rtems/bspIo.h>
#include <rtems/sysinit.h>
#include <rtems/score/sysstate.h>

#include <rtems/test.h>

/**
 * @defgroup RTEMSTestSuiteTestsuitesValidationProfile \
 *   spec:/testsuites/validation/profile
 *
 * @ingroup RTEMSTestSuites
 *
 * @brief This test suite contains test cases which call in combination all
 *   functions included in the space profile.
 *
 * @{
 */

#define NAME rtems_build_name('N', 'A', 'M', 'E')

static void fatal_extension(
  rtems_fatal_source source,
  bool always_set_to_false,
  rtems_fatal_code error
)
{
  T_make_runner();
  T_step_eq_int(0, source, RTEMS_FATAL_SOURCE_APPLICATION);
  T_step_false(1, always_set_to_false, "always_set_to_false");
  T_step_eq_ulong(2, error, 123);
  T_case_end();
  T_run_finalize();
}

static void Init(rtems_task_argument arg)
{
  (void) arg;

  T_make_runner();
  T_register();
  T_run_all();
  T_case_begin("SpaceProfileFatalError", NULL);
  T_plan(3);
  rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 123);
}

#define INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES

#define MAX_TLS_SIZE RTEMS_ALIGN_UP(64, RTEMS_TASK_STORAGE_ALIGNMENT)

RTEMS_ALIGNED(RTEMS_TASK_STORAGE_ALIGNMENT) static char init_task_storage[
  RTEMS_TASK_STORAGE_SIZE(
    MAX_TLS_SIZE + RTEMS_MINIMUM_STACK_SIZE,
    INIT_TASK_ATTRIBUTES
  )
];

static char buffer[512];

static void check_task_context(T_event event, const char *name)
{
  if (_System_state_Is_up(_System_state_Get())) {
    T_check_task_context(event, name);
  }
}

static const T_action actions[] = {
  T_report_hash_sha256,
  check_task_context,
  T_check_rtems_barriers,
  T_check_rtems_extensions,
  T_check_rtems_message_queues,
  T_check_rtems_partitions,
  T_check_rtems_periods,
  T_check_rtems_semaphores,
  T_check_rtems_tasks,
  T_check_rtems_timers
};

static const T_config test_config = {
  .name = "SpaceProfile",
  .buf = buffer,
  .buf_size = sizeof(buffer),
  .putchar = rtems_put_char,
  .verbosity = T_VERBOSE,
  .now = T_now_clock,
  .action_count = T_ARRAY_SIZE(actions),
  .actions = actions
};

static const rtems_task_config task_config = {
  .name = NAME,
  .initial_priority = 1,
  .storage_area = init_task_storage,
  .storage_size = sizeof(init_task_storage),
  .maximum_thread_local_storage_size = MAX_TLS_SIZE,
  .initial_modes = RTEMS_DEFAULT_MODES,
  .attributes = INIT_TASK_ATTRIBUTES
};

static void init_task(void)
{
  rtems_id id;
  rtems_status_code sc;

  T_run_initialize(&test_config);
  T_case_begin("SpaceProfileTaskBuild", NULL);
  T_plan(2);

  sc = rtems_task_construct(&task_config, &id);
  T_step_rsc_success(0, sc);

  sc = rtems_task_start(id, Init, 0);
  T_step_rsc_success(1, sc);

  T_check_rtems_tasks(T_EVENT_RUN_INITIALIZE_EARLY, T_case_name());
  T_case_end();
}

RTEMS_SYSINIT_ITEM(
  init_task,
  RTEMS_SYSINIT_CLASSIC_USER_TASKS,
  RTEMS_SYSINIT_ORDER_MIDDLE
);

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_PROCESSORS 4

#define CONFIGURE_MAXIMUM_BARRIERS 1

#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1

#define CONFIGURE_MAXIMUM_PARTITIONS 1

#define CONFIGURE_MAXIMUM_PERIODS 1

#define CONFIGURE_MAXIMUM_SEMAPHORES 1

#define CONFIGURE_MAXIMUM_TASKS 1

#define CONFIGURE_MAXIMUM_TIMERS 1

#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1

#define CONFIGURE_MESSAGE_BUFFER_MEMORY 1

#define CONFIGURE_MICROSECONDS_PER_TICK 10000

#define CONFIGURE_SCHEDULER_NAME NAME

#define CONFIGURE_INITIAL_EXTENSIONS { .fatal = fatal_extension }

/* Mandatory for space profile */

#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0

#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY

#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM

#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION

#define CONFIGURE_IDLE_TASK_BODY _CPU_Thread_Idle_body

#define CONFIGURE_INIT

#include <rtems/confdefs.h>

/** @} */