The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
init_test.c
Go to the documentation of this file.
1 
9 #include <test.h>
10 
11 #include <core/arg_parse.h>
12 #include <core/init.h>
13 
14 void log_logo_print(void) {}
15 
17 {
18  return false;
19 }
20 
21 static unsigned mocked_threads;
22 
23 unsigned thread_cores_count(void) {
24  return mocked_threads;
25 }
26 
28 
29 char *args_lp[] = {
30  "init_test",
31  "--lp",
32  "64",
33  NULL
34 };
35 
36 char *args_wt[] = {
37  "init_test",
38  "--wt",
39  "400",
40  "--lp",
41  "800",
42  NULL
43 };
44 
45 char *args_serial[] = {
46  "init_test",
47  "--serial",
48  "--lp",
49  "128",
50  NULL
51 };
52 
53 char *args_no_bind[] = {
54  "init_test",
55  "--lp",
56  "256",
57  "--no-bind",
58  NULL
59 };
60 
61 char *args_gvt[] = {
62  "init_test",
63  "--lp",
64  "25",
65  "--gvt-period",
66  "500",
67  NULL
68 };
69 
70 char *args_termination[] = {
71  "init_test",
72  "--lp",
73  "16",
74  "--time",
75  "1437.23",
76  NULL
77 };
78 
79 char *args_seed[] = {
80  "init_test",
81  "--lp",
82  "16",
83  "--seed",
84  "23491",
85  NULL
86 };
87 
88 #define TEST_INIT(args_arr, cond) \
89 __extension__({ \
90  init_args_parse(sizeof(args_arr) / sizeof(*(args_arr)) - 1, \
91  (args_arr)); \
92  if (!(cond)) return -1; \
93 })
94 
95 int main(int argc, char **argv)
96 {
97  (void) argc;
98  (void) argv;
99 
100  mocked_threads = 81;
101 
102  TEST_INIT(args_lp,
103  n_lps == 64 &&
104  n_threads == 81 &&
107  global_config.gvt_period == 200000 &&
108  global_config.prng_seed == 0 &&
110 
111  mocked_threads = 1024;
112 
113  TEST_INIT(args_lp,
114  n_lps == 64 &&
115  n_threads == 1024 &&
118  global_config.gvt_period == 200000 &&
119  global_config.prng_seed == 0 &&
121 
122  TEST_INIT(args_wt,
123  n_lps == 800 &&
124  n_threads == 400 &&
127  global_config.gvt_period == 200000 &&
128  global_config.prng_seed == 0 &&
130 
131  TEST_INIT(args_serial,
132  n_lps == 128 &&
133  n_threads == 1 &&
136  global_config.gvt_period == 200000 &&
137  global_config.prng_seed == 0 &&
139 
140  TEST_INIT(args_no_bind,
141  n_lps == 256 &&
142  n_threads == 1024 &&
145  global_config.gvt_period == 200000 &&
146  global_config.prng_seed == 0 &&
148 
149  TEST_INIT(args_gvt,
150  n_lps == 25 &&
151  n_threads == 1024 &&
154  global_config.gvt_period == 500000 &&
155  global_config.prng_seed == 0 &&
157 
158  TEST_INIT(args_termination,
159  n_lps == 16 &&
160  n_threads == 1024 &&
163  global_config.gvt_period == 200000 &&
164  global_config.prng_seed == 0 &&
165  global_config.termination_time == 1437.23);
166 
167  TEST_INIT(args_seed,
168  n_lps == 16 &&
169  n_threads == 1024 &&
172  global_config.gvt_period == 200000 &&
173  global_config.prng_seed == 23491 &&
175 
176  test_printf("test done");
177  return 0;
178 }
179 
180 const struct test_config test_config = {
181  .expected_output = "test done",
182  .expected_output_size = sizeof("test done") - 1
183 };
n_lps
lp_id_t n_lps
The total number of LPs in the simulation.
Definition: core.c:13
simulation_configuration::core_binding
bool core_binding
If set, worker threads are bound to physical cores.
Definition: init.h:30
thread_cores_count
unsigned thread_cores_count(void)
Computes the count of available cores on the machine.
Definition: init_test.c:23
simulation_configuration::termination_time
simtime_t termination_time
The target termination logical time.
Definition: init.h:22
simulation_configuration::gvt_period
unsigned gvt_period
The gvt period expressed in microseconds.
Definition: init.h:24
n_threads
rid_t n_threads
The total number of MPI nodes in the simulation.
Definition: core.c:15
main
int main(int argc, char **argv)
The main entry point of the custom compiler.
Definition: init_test.c:95
SIMTIME_MAX
#define SIMTIME_MAX
The maximum value of the logical simulation time, semantically never.
Definition: core.h:64
simulation_configuration::is_serial
bool is_serial
If set, the simulation will run on the serial runtime.
Definition: init.h:32
log_logo_print
void log_logo_print(void)
Prints a fancy ROOT-Sim logo on the terminal.
Definition: init_test.c:14
test_config
A complete test configuration.
Definition: test.h:22
init.h
Initialization routines.
io_terminal_can_colorize
bool io_terminal_can_colorize(void)
Determines if stdout supports colored text.
Definition: init_test.c:16
log_colored
bool log_colored
If set, uses color codes to color the log outputs.
Definition: init_test.c:27
test.h
Test framework header.
test_config::expected_output
const char * expected_output
The expected output from the whole sequence of test_printf() calls.
Definition: test.h:35
test_printf
int test_printf(const char *restrict fmt,...)
Registers a formatted string to compare against the expected output.
Definition: test.c:169
arg_parse.h
Command line option parser.
global_config
struct simulation_configuration global_config
The configuration filled in by init_args_parse()
Definition: init.c:27
simulation_configuration::prng_seed
uint64_t prng_seed
The seed used to initialize the pseudo random numbers.
Definition: init.h:28