1 /* Copyright (c) 2023 Nordic Semiconductor ASA
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5 #include "bs_types.h"
6 #include "bs_tracing.h"
7 #include "bstests.h"
8
9 #include <zephyr/logging/log.h>
10 LOG_MODULE_REGISTER(bt_bsim_ead_sample_data, CONFIG_BT_EAD_LOG_LEVEL);
11
12 extern enum bst_result_t bst_result;
13
14 #define WAIT_TIME_S 20
15 #define WAIT_TIME (WAIT_TIME_S * 1e6)
16
17 extern void test_central(void);
18 extern void test_peripheral(void);
19 extern void test_args_parse(int argc, char *argv[]);
20
test_tick(bs_time_t HW_device_time)21 void test_tick(bs_time_t HW_device_time)
22 {
23 if (bst_result != Passed) {
24 bst_result = Failed;
25 bs_trace_error_time_line("Test failed (not passed after %d seconds)\n",
26 WAIT_TIME_S);
27 }
28 }
29
test_ead_sample_data_init(void)30 static void test_ead_sample_data_init(void)
31 {
32 bst_ticker_set_next_tick_absolute(WAIT_TIME);
33 bst_result = In_progress;
34 }
35
36 static const struct bst_test_instance test_def[] = {
37 {
38 .test_id = "central",
39 .test_descr = "Central device",
40 .test_pre_init_f = test_ead_sample_data_init,
41 .test_tick_f = test_tick,
42 .test_main_f = test_central,
43 .test_args_f = test_args_parse,
44 },
45 {
46 .test_id = "peripheral",
47 .test_descr = "Peripheral device",
48 .test_pre_init_f = test_ead_sample_data_init,
49 .test_tick_f = test_tick,
50 .test_main_f = test_peripheral,
51 .test_args_f = test_args_parse,
52 },
53 BSTEST_END_MARKER};
54
test_encrypted_ad_data_install(struct bst_test_list * tests)55 struct bst_test_list *test_encrypted_ad_data_install(struct bst_test_list *tests)
56 {
57 return bst_add_tests(tests, test_def);
58 }
59
60 bst_test_install_t test_installers[] = {test_encrypted_ad_data_install, NULL};
61
main(void)62 int main(void)
63 {
64 bst_main();
65 return 0;
66 }
67