The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
test.c File Reference

Test framework source. More...

#include <test.h>
#include <arch/thread.h>
#include <limits.h>
#include <memory.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdlib.h>
+ Include dependency graph for test.c:

Go to the source code of this file.

Macros

#define ROOTSIM_TEST_NAME   "rs_test"
 

Functions

void _log_log (int level, const char *file, unsigned line, const char *fmt,...)
 Logs a message. For internal use: log_log() should be used instead. More...
 
int main (int argc, char **argv)
 The main entry point of the custom compiler. More...
 
static int init_arguments (int *argc_p, char ***argv_p)
 Initializes ISO C compliant argc and argv from the test configuration. More...
 
static void test_atexit (void)
 The exit handler, to exit cleanly even in case of errors.
 
void main_wrapper (void)
 The test wrapper which allows to intervene before the actual main()
 
static int test_printf_internal (const char *restrict fmt, va_list args)
 
int test_printf (const char *restrict fmt,...)
 Registers a formatted string to compare against the expected output. More...
 
int test_printf_pr (const char *restrict fmt,...)
 Registers a formatted string to compare against the expected output. More...
 
bool test_thread_barrier (void)
 Synchronizes threads on a barrier. More...
 

Variables

static char * t_out_buf
 
static size_t t_out_buf_size
 
static size_t t_out_wrote
 
static char ** test_argv
 
lp_id_t n_lps
 The total number of LPs in the simulation.
 
nid_t nid
 The node identifier of the node.
 
nid_t n_nodes = 1
 
rid_t n_threads
 The total number of MPI nodes in the simulation.
 
__thread rid_t rid
 The identifier of the thread.
 
int log_level
 The minimum log level of the messages to display.
 

Detailed Description

Test framework source.

The source of the minimal test framework used in the code base tests

Definition in file test.c.

Function Documentation

◆ _log_log()

void _log_log ( int  level,
const char *  file,
unsigned  line,
const char *  fmt,
  ... 
)

Logs a message. For internal use: log_log() should be used instead.

Parameters
levelthe importance level of the message to log
filethe file name where this function is being called
linethe line number where this function is being called
fmta printf-style format string for the message to log
...the list of arguments to fill in the format string fmt

Definition at line 43 of file test.c.

◆ init_arguments()

static int init_arguments ( int *  argc_p,
char ***  argv_p 
)
static

Initializes ISO C compliant argc and argv from the test configuration.

Parameters
argc_pa pointer to a variable which will hold the computed argc value
argv_pa pointer to a variable which will hold the computer argv value
Returns
0 in case of success, -1 in case of failure

Definition at line 59 of file test.c.

◆ main()

int main ( int  argc,
char **  argv 
)

The main entry point of the custom compiler.

Parameters
argcThe count of command line arguments, as per ISO C standard
argvThe list of command line arguments, as per ISO C standard

Definition at line 62 of file compiler.c.

+ Here is the call graph for this function:

◆ test_printf()

int test_printf ( const char *restrict  fmt,
  ... 
)

Registers a formatted string to compare against the expected output.

Returns
the number of successfully registered characters

Definition at line 169 of file test.c.

+ Here is the caller graph for this function:

◆ test_printf_pr()

int test_printf_pr ( const char *restrict  fmt,
  ... 
)

Registers a formatted string to compare against the expected output.

Returns
the number of successfully registered characters

Cloned definition needed because the LLVM plugin expects a suffixed symbol

Definition at line 184 of file test.c.

◆ test_thread_barrier()

bool test_thread_barrier ( void  )

Synchronizes threads on a barrier.

Returns
true if this thread has been elected as leader, false otherwise

This is a more battle tested although less performing version of the thread barrier. We can't rely on the pthread barrier because it's not portable.

Definition at line 200 of file test.c.

+ Here is the caller graph for this function: