RTEMS CPU Kit with SuperCore  4.11.3
test.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
3  *
4  * embedded brains GmbH
5  * Dornierstr. 4
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.org/license/LICENSE.
13  */
14 
15 #ifndef _RTEMS_TEST_H
16 #define _RTEMS_TEST_H
17 
18 #include <rtems.h>
19 #include <rtems/bspIo.h>
20 #include <rtems/score/atomic.h>
21 #include <rtems/score/smpbarrier.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
38 extern const char rtems_test_name[];
39 
44  rtems_fatal_source source,
45  bool is_internal,
46  rtems_fatal_code code
47 );
48 
52 #define RTEMS_TEST_INITIAL_EXTENSION \
53  { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension }
54 
64  rtems_printk_plugin_t printf_func,
65  void *printf_arg
66 );
67 
73 static inline int rtems_test_begin(void)
74 {
76 }
77 
83 static inline int rtems_test_begink(void)
84 {
86 }
87 
97  rtems_printk_plugin_t printf_func,
98  void *printf_arg
99 );
100 
106 static inline int rtems_test_end(void)
107 {
109 }
110 
116 static inline int rtems_test_endk(void)
117 {
119 }
120 
124 typedef struct {
125  Atomic_Ulong stop;
126  SMP_barrier_Control barrier;
127  size_t worker_count;
128  rtems_id worker_ids[32];
129  rtems_id stop_worker_timer_id;
131 
142 typedef void (*rtems_test_parallel_worker_setup)(
144  size_t worker_index,
145  rtems_id worker_id
146 );
147 
151 typedef struct {
166  rtems_interval (*init)(
168  void *arg,
169  size_t active_workers
170  );
171 
182  void (*body)(
184  void *arg,
185  size_t active_workers,
186  size_t worker_index
187  );
188 
200  void (*fini)(
202  void *arg,
203  size_t active_workers
204  );
205 
209  void *arg;
218  bool cascade;
220 
229 static inline bool rtems_test_parallel_stop_job(
230  const rtems_test_parallel_context *ctx
231 )
232 {
233  return _Atomic_Load_ulong(&ctx->stop, ATOMIC_ORDER_RELAXED) != 0;
234 }
235 
246 static inline bool rtems_test_parallel_is_master_worker(size_t worker_index)
247 {
248  return worker_index == 0;
249 }
250 
259 static inline rtems_id rtems_test_parallel_get_task_id(
260  const rtems_test_parallel_context *ctx,
261  size_t worker_index
262 )
263 {
264  return ctx->worker_ids[worker_index];
265 }
266 
283  const rtems_test_parallel_job *jobs,
284  size_t job_count
285 );
286 
289 #ifdef __cplusplus
290 }
291 #endif /* __cplusplus */
292 
293 #endif /* _RTEMS_TEST_H */
int rtems_test_begin_with_plugin(rtems_printk_plugin_t printf_func, void *printf_arg)
Prints a begin of test message.
Definition: testbeginend.c:22
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:80
const char rtems_test_name[]
Each test must define a test name string.
SMP barrier control.
Definition: smpbarrier.h:51
SMP Barrier API.
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.h:143
Basic parallel job description.
Definition: test.h:152
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:119
int printk_plugin(void *context, const char *fmt,...)
Reporting Methods printk() Plugin.
Definition: printk_plugin.c:24
void rtems_test_fatal_extension(rtems_fatal_source source, bool is_internal, rtems_fatal_code code)
Fatal extension for tests.
Definition: testextension.c:29
Internal context for parallel job execution.
Definition: test.h:125
int rtems_printf_plugin(void *context, const char *fmt,...)
Reporting Methods printf() Plugin.
Definition: printf_plugin.c:30
Interface to Kernel Print Methods.
Definition: inftrees.h:25
int(* rtems_printk_plugin_t)(void *, const char *format,...)
Type definition for function which can be plugged in to certain reporting routines to redirect the ou...
Definition: bspIo.h:129
int rtems_test_end_with_plugin(rtems_printk_plugin_t printf_func, void *printf_arg)
Prints an end of test message.
Definition: testbeginend.c:34
Atomic Operations API.
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:120
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:45