1 /**
2  * Common functions and helpers
3  *
4  * Copyright (c) 2023 Nordic Semiconductor ASA
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #ifndef ZEPHYR_TEST_BSIM_BT_AUDIO_TEST_
10 #define ZEPHYR_TEST_BSIM_BT_AUDIO_TEST_
11 
12 #include <zephyr/kernel.h>
13 
14 #include "bs_types.h"
15 #include "bs_tracing.h"
16 #include "time_machine.h"
17 #include "bstests.h"
18 
19 #include <zephyr/types.h>
20 #include <stddef.h>
21 #include <errno.h>
22 #include <zephyr/sys_clock.h>
23 
24 #include <zephyr/bluetooth/bluetooth.h>
25 #include <zephyr/bluetooth/hci.h>
26 #include <zephyr/bluetooth/conn.h>
27 #include <zephyr/bluetooth/uuid.h>
28 #include <zephyr/bluetooth/gatt.h>
29 
30 #define WAIT_SECONDS 30                         /* seconds */
31 #define WAIT_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/
32 
33 #define CREATE_FLAG(flag) static atomic_t flag = (atomic_t)false
34 #define SET_FLAG(flag) (void)atomic_set(&flag, (atomic_t)true)
35 #define UNSET_FLAG(flag) (void)atomic_set(&flag, (atomic_t)false)
36 #define TEST_FLAG(flag) (atomic_get(&flag) == (atomic_t)true)
37 #define WAIT_FOR_FLAG(flag) \
38 	while (!(bool)atomic_get(&flag)) { \
39 		(void)k_sleep(K_MSEC(1)); \
40 	}
41 
42 #define FAIL(...) \
43 	do { \
44 		bst_result = Failed; \
45 		bs_trace_error_time_line(__VA_ARGS__); \
46 	} while (0)
47 
48 #define PASS(...) \
49 	do { \
50 		bst_result = Passed; \
51 		bs_trace_info_time(1, "PASSED: " __VA_ARGS__); \
52 	} while (0)
53 
54 void test_tick(bs_time_t HW_device_time);
55 void test_init(void);
56 
57 extern uint8_t mfg_data[254];
58 
59 #endif /* ZEPHYR_TEST_BSIM_BT_AUDIO_TEST_ */
60