1 /* Copyright (c) 2023 Nordic Semiconductor ASA 2 * SPDX-License-Identifier: Apache-2.0 3 */ 4 5 #include <bs_tracing.h> 6 #include <bs_types.h> 7 #include <bstests.h> 8 9 #define BS_SECONDS(dur_sec) ((bs_time_t)dur_sec * 1000000) 10 #define SIMULATED_TEST_TIMEOUT BS_SECONDS(60) 11 12 void the_test(void); 13 extern enum bst_result_t bst_result; 14 test_init(void)15void test_init(void) 16 { 17 bst_result = In_progress; 18 bst_ticker_set_next_tick_absolute(SIMULATED_TEST_TIMEOUT); 19 } 20 test_tick(bs_time_t HW_device_time)21void test_tick(bs_time_t HW_device_time) 22 { 23 bs_trace_debug_time(0, "Simulation ends now.\n"); 24 if (bst_result == In_progress) { 25 bst_result = Failed; 26 bs_trace_error("Test did not pass before simulation ended. Consider increasing " 27 "simulation length.\n"); 28 } 29 } 30 31 static const struct bst_test_instance test_to_add[] = { 32 { 33 .test_id = "the_test", 34 .test_pre_init_f = test_init, 35 .test_tick_f = test_tick, 36 .test_main_f = the_test, 37 }, 38 BSTEST_END_MARKER, 39 }; 40 install(struct bst_test_list * tests)41static struct bst_test_list *install(struct bst_test_list *tests) 42 { 43 return bst_add_tests(tests, test_to_add); 44 }; 45 46 bst_test_install_t test_installers[] = {install, NULL}; 47 main(void)48int main(void) 49 { 50 bst_main(); 51 52 return 0; 53 } 54