The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
test.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 
19 #define TEST_BAD_FAIL_EXIT_CODE 99
20 
22 struct test_config {
24 
25  int (*test_init_fnc)(void);
27 
28  int (*test_fini_fnc)(void);
30 
31  int (*test_fnc)(void);
33  unsigned threads_count;
35  const char *expected_output;
39  const char **test_arguments;
40 };
41 
43 extern const struct test_config test_config;
44 
45 extern int test_printf(const char *restrict fmt, ...);
46 extern bool test_thread_barrier(void);
47 
48 // core.c mock
49 typedef uint64_t lp_id_t;
50 typedef unsigned rid_t;
51 typedef int nid_t;
rid_t
unsigned rid_t
Used to identify in a node the computing resources (threads at the moment)
Definition: core.h:77
nid_t
int nid_t
Used to identify MPI nodes in a distributed environment.
Definition: core.h:79
test_config::test_init_fnc
int(* test_init_fnc)(void)
The test initialization function.
Definition: test.h:25
test_config::test_fini_fnc
int(* test_fini_fnc)(void)
The test finalization function.
Definition: test.h:28
test_config
A complete test configuration.
Definition: test.h:22
test_thread_barrier
bool test_thread_barrier(void)
Synchronizes threads on a barrier.
Definition: test.c:200
test_printf
int test_printf(const char *restrict fmt,...)
Registers a formatted string to compare against the expected output.
Definition: test.c:169
test_config::expected_output
const char * expected_output
The expected output from the whole sequence of test_printf() calls.
Definition: test.h:35
test_config::test_fnc
int(* test_fnc)(void)
The core test function.
Definition: test.h:31
test_config::expected_output_size
size_t expected_output_size
The expected output size of the full sequence of test_printf() calls.
Definition: test.h:37
lp_id_t
uint64_t lp_id_t
Used to uniquely identify LPs in the simulation.
Definition: core.h:75
test_config::test_arguments
const char ** test_arguments
The command line arguments passed to the wrapped main function.
Definition: test.h:39
test_config::threads_count
unsigned threads_count
test_fnc is executed with that many cores
Definition: test.h:33