Skip to content

Commit c2c4f2e

Browse files
HaavardReikartben
authored andcommitted
Bluetooth: tests: Add macros to babblekit
Adds two macros to the babblekit library: * DEFINE_FLAG_STATIC * TEST_ASSERT_NO_MSG Signed-off-by: Håvard Reierstad <[email protected]>
1 parent 997814c commit c2c4f2e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/bsim/babblekit/include/babblekit/flags.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@
1919
#define DECLARE_FLAG(flag) extern atomic_t flag
2020

2121
/* Define a new binary flag.
22-
* Declare them static if defining flags with the same name in multiple files.
22+
* Use @ref DEFINE_FLAG_STATIC if defining flags with the same name in multiple files.
2323
*
2424
* @param flag Name of the flag
2525
*/
2626
#define DEFINE_FLAG(flag) atomic_t flag = (atomic_t) false
2727

28+
/* Define a new, static binary flag.
29+
*
30+
* @param flag Name of the flag
31+
*/
32+
#define DEFINE_FLAG_STATIC(flag) static atomic_t flag = (atomic_t) false
33+
2834
#define SET_FLAG(flag) (void)atomic_set(&flag, (atomic_t) true)
2935
#define UNSET_FLAG(flag) (void)atomic_set(&flag, (atomic_t) false)
3036

tests/bsim/babblekit/include/babblekit/testcase.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ extern enum bst_result_t bst_result;
9595
} \
9696
} while (0)
9797

98+
/*
99+
* @brief Assert `expr` is true
100+
*
101+
* Assert that `expr` is true. If assertion is false, fail the test. I.e. return non-zero.
102+
*
103+
* @note This is different than `sys/__assert.h`.
104+
*
105+
*/
106+
#define TEST_ASSERT_NO_MSG(expr) \
107+
TEST_ASSERT(expr, "")
108+
98109
/*
99110
* @brief Print a value. Lower-level than `printk` or `LOG_xx`.
100111
*

0 commit comments

Comments
 (0)