Line data Source code
1 1 : /** 2 : * @file test/test.h 3 : * 4 : * @brief Test framework header 5 : * 6 : * The header of the minimal test framework used in the code base tests 7 : * 8 : * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com> 9 : * SPDX-License-Identifier: GPL-3.0-only 10 : */ 11 : #pragma once 12 : 13 : #include <stdbool.h> 14 : #include <stddef.h> 15 : #include <stdint.h> 16 : #include <stdio.h> 17 : 18 : /// The exit code of tests when something fails horribly 19 1 : #define TEST_BAD_FAIL_EXIT_CODE 99 20 : 21 : /// A complete test configuration 22 1 : struct test_config { 23 : /// The test initialization function 24 : /** The return value is used as failure exit code if it is non-zero */ 25 1 : int (*test_init_fnc)(void); 26 : /// The test finalization function 27 : /** The return value is used as failure exit code if it is non-zero */ 28 1 : int (*test_fini_fnc)(void); 29 : /// The core test function 30 : /** The return value is used as failure exit code if it is non-zero. */ 31 1 : int (*test_fnc)(void); 32 : /// @a test_fnc is executed with that many cores 33 1 : unsigned threads_count; 34 : /// The command line arguments passed to the wrapped main function 35 1 : const char **test_arguments; 36 : }; 37 : 38 : /// The test configuration object, must be defined by the test sources 39 : extern const struct test_config test_config; 40 1 : extern bool test_thread_barrier(void); 41 : 42 : // core.c mock 43 0 : typedef uint64_t lp_id_t; 44 0 : typedef unsigned rid_t; 45 0 : typedef int nid_t;