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