RTEMS 6.1-rc1
test-info.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG
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#ifndef _RTEMS_TEST_H
37#define _RTEMS_TEST_H
38
39#include <rtems.h>
40#include <rtems/score/atomic.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
60extern const char rtems_test_name[];
61
66 rtems_fatal_source source,
67 bool always_set_to_false,
69);
70
74#define RTEMS_TEST_INITIAL_EXTENSION \
75 { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension, NULL }
76
80typedef enum
81{
82 RTEMS_TEST_STATE_PASS,
83 RTEMS_TEST_STATE_FAIL,
84 RTEMS_TEST_STATE_USER_INPUT,
85 RTEMS_TEST_STATE_INDETERMINATE,
86 RTEMS_TEST_STATE_BENCHMARK
88
89#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
90 (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
91 (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
92 (TEST_STATE_USER_INPUT && TEST_STATE_INDETERMINATE) || \
93 (TEST_STATE_USER_INPUT && TEST_STATE_BENCHMARK) || \
94 (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
95 #error Test states must be unique
96#endif
97
98#if TEST_STATE_EXPECTED_FAIL
99 #define TEST_STATE RTEMS_TEST_STATE_FAIL
100#elif TEST_STATE_USER_INPUT
101 #define TEST_STATE RTEMS_TEST_STATE_USER_INPUT
102#elif TEST_STATE_INDETERMINATE
103 #define TEST_STATE RTEMS_TEST_STATE_INDETERMINATE
104#elif TEST_STATE_BENCHMARK
105 #define TEST_STATE RTEMS_TEST_STATE_BENCHMARK
106#else
107 #define TEST_STATE RTEMS_TEST_STATE_PASS
108#endif
109
115int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state);
116
122int rtems_test_end(const char* name);
123
128RTEMS_NO_RETURN void rtems_test_exit(int status);
129
130#define RTEMS_TEST_PARALLEL_PROCESSOR_MAX 32
131
133
137typedef struct {
138 Atomic_Ulong stop;
139 SMP_barrier_Control barrier;
140 size_t worker_count;
141 rtems_id worker_ids[RTEMS_TEST_PARALLEL_PROCESSOR_MAX];
142 rtems_id stop_worker_timer_id;
143 const struct rtems_test_parallel_job *jobs;
144 size_t job_count;
146
159 size_t worker_index,
160 rtems_id worker_id
161);
162
183 void *arg,
184 size_t active_workers
185 );
186
197 void (*body)(
199 void *arg,
200 size_t active_workers,
201 size_t worker_index
202 );
203
215 void (*fini)(
217 void *arg,
218 size_t active_workers
219 );
220
224 void *arg;
225
234};
235
244static inline bool rtems_test_parallel_stop_job(
246)
247{
248 return _Atomic_Load_ulong(&ctx->stop, ATOMIC_ORDER_RELAXED) != 0;
249}
250
261static inline bool rtems_test_parallel_is_master_worker(size_t worker_index)
262{
263 return worker_index == 0;
264}
265
274static inline rtems_id rtems_test_parallel_get_task_id(
276 size_t worker_index
277)
278{
279 return ctx->worker_ids[worker_index];
280}
281
298 const rtems_test_parallel_job *jobs,
299 size_t job_count
300);
301
313void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds);
314
326 const RTEMS_TEST_STATE state
327);
328
333void rtems_test_gcov_dump_info( void );
334
337#ifdef __cplusplus
338}
339#endif /* __cplusplus */
340
341#endif /* _RTEMS_TEST_H */
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
Definition: basedefs.h:386
CPU_Uint32ptr rtems_task_argument
This integer type represents task argument values.
Definition: tasks.h:100
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
Watchdog_Interval rtems_interval
This type represents clock tick intervals.
Definition: types.h:114
Internal_errors_t rtems_fatal_code
This integer type represents system termination codes.
Definition: extension.h:161
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:63
void rtems_test_gcov_dump_info(void)
Dumps the gcov information as a base64 encoded gcfn and gcda data stream using rtems_put_char().
Definition: testgcovdumpinfo.c:63
void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds)
Performs a busy loop for the specified seconds and nanoseconds based on the CPU usage of the executin...
Definition: testbusy.c:36
RTEMS_NO_RETURN void rtems_test_exit(int status)
Exit the test without calling exit() since it closes stdin, etc and pulls in stdio code.
Definition: testbeginend.c:106
const char rtems_test_name[]
Each test must define a test name string.
Definition: init.c:6903
RTEMS_NO_RETURN void rtems_test_run(rtems_task_argument arg, const RTEMS_TEST_STATE state)
Runs the test cases of the RTEMS Test Framework using a default configuration in the context of a tas...
Definition: testrun.c:76
void rtems_test_fatal_extension(rtems_fatal_source source, bool always_set_to_false, rtems_fatal_code code)
Fatal extension for tests.
Definition: testextension.c:43
void(* rtems_test_parallel_worker_setup)(rtems_test_parallel_context *ctx, size_t worker_index, rtems_id worker_id)
Worker task setup handler.
Definition: test-info.h:157
RTEMS_TEST_STATE
Test states.
Definition: test-info.h:81
void rtems_test_parallel(rtems_test_parallel_context *ctx, rtems_test_parallel_worker_setup worker_setup, const rtems_test_parallel_job *jobs, size_t job_count)
Runs a bunch of jobs in parallel on all processors of the system.
Definition: testparallel.c:136
int rtems_test_begin(const char *name, const RTEMS_TEST_STATE state)
Prints a begin of test message using printf().
Definition: testbeginend.c:61
int rtems_test_end(const char *name)
Prints an end of test message using printf().
Definition: testbeginend.c:98
This header file provides the interfaces of the Atomic Operations.
This header file defines the RTEMS Classic API.
This header file provides the interfaces of the SMP Barriers.
SMP barrier control.
Definition: smpbarrier.h:67
Definition: inftrees.h:24
Internal context for parallel job execution.
Definition: test-info.h:137
Basic parallel job description.
Definition: test-info.h:166
rtems_interval(* init)(rtems_test_parallel_context *ctx, void *arg, size_t active_workers)
Job initialization handler.
Definition: test-info.h:181
void * arg
Job specific argument.
Definition: test-info.h:224
void(* body)(rtems_test_parallel_context *ctx, void *arg, size_t active_workers, size_t worker_index)
Job body handler.
Definition: test-info.h:197
void(* fini)(rtems_test_parallel_context *ctx, void *arg, size_t active_workers)
Job finalization handler.
Definition: test-info.h:215
bool cascade
Job cascading flag.
Definition: test-info.h:233