1 /*
2  * Common functions and helpers for L2CAP tests
3  *
4  * Copyright (c) 2022 Nordic Semiconductor ASA
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <stddef.h>
10 
11 #include "bs_types.h"
12 #include "bs_tracing.h"
13 #include "bstests.h"
14 
15 #define CREATE_FLAG(flag) static atomic_t flag = (atomic_t)false
16 #define SET_FLAG(flag) (void)atomic_set(&flag, (atomic_t)true)
17 #define UNSET_FLAG(flag) (void)atomic_set(&flag, (atomic_t)false)
18 #define WAIT_FOR_FLAG_SET(flag)		   \
19 	while (!(bool)atomic_get(&flag)) { \
20 		(void)k_sleep(K_MSEC(1));  \
21 	}
22 #define WAIT_FOR_FLAG_UNSET(flag)	  \
23 	while ((bool)atomic_get(&flag)) { \
24 		(void)k_sleep(K_MSEC(1)); \
25 	}
26 
27 
28 #define WAIT_TIME (30e6) /* 30 seconds*/
29 
30 #define FAIL(...)				       \
31 	do {					       \
32 		bst_result = Failed;		       \
33 		bs_trace_error_time_line(__VA_ARGS__); \
34 	} while (0)
35 
36 #define PASS(...)				    \
37 	do {					    \
38 		bst_result = Passed;		    \
39 		bs_trace_info_time(1, __VA_ARGS__); \
40 	} while (0)
41 
42 
43 void test_init(void);
44 void test_tick(bs_time_t HW_device_time);
45