ztest API Migration: bluetooth/ctrl_sw_privacy_unit
Migrate the unit tests at `bluetooth/ctrl_sw_privacy_unit` to
use the new ztest API.
Signed-off-by: Tristan Honscheid <honscheid@google.com>
diff --git a/tests/bluetooth/ctrl_sw_privacy_unit/prj.conf b/tests/bluetooth/ctrl_sw_privacy_unit/prj.conf
index 5feb77f..9325a62 100644
--- a/tests/bluetooth/ctrl_sw_privacy_unit/prj.conf
+++ b/tests/bluetooth/ctrl_sw_privacy_unit/prj.conf
@@ -3,4 +3,5 @@
CONFIG_ZTEST_ASSERT_VERBOSE=3
CONFIG_ZTEST_STACK_SIZE=4096
CONFIG_ZTEST_MOCKING=y
+CONFIG_ZTEST_NEW_API=y
CONFIG_ZTEST_PARAMETER_COUNT=32
diff --git a/tests/bluetooth/ctrl_sw_privacy_unit/src/main.c b/tests/bluetooth/ctrl_sw_privacy_unit/src/main.c
index b22484c..6fcde31 100644
--- a/tests/bluetooth/ctrl_sw_privacy_unit/src/main.c
+++ b/tests/bluetooth/ctrl_sw_privacy_unit/src/main.c
@@ -51,7 +51,7 @@
prpa_cache_add(&a1);
pos = prpa_cache_find(&a1);
ex_pos = (1 + skew) % CONFIG_BT_CTLR_RPA_CACHE_SIZE;
- zassert_equal(pos, ex_pos, "");
+ zassert_equal(pos, ex_pos, "%d == %d", pos, ex_pos);
prpa_cache_add(&a2);
pos = prpa_cache_find(&a2);
@@ -80,19 +80,27 @@
zassert_equal(pos, FILTER_IDX_NONE, "");
}
-void test_privacy_clear(void)
+static void before(void *data)
{
- prpa_cache_clear();
+ ARG_UNUSED(data);
+ /* Run before each test - clear the cache so we start fresh each time. */
+ prpa_cache_clear();
+}
+
+ZTEST_SUITE(test_ctrl_sw_privacy_unit, NULL, NULL, before, NULL, NULL);
+
+ZTEST(test_ctrl_sw_privacy_unit, test_privacy_clear)
+{
helper_privacy_clear();
}
-void test_privacy_add(void)
+ZTEST(test_ctrl_sw_privacy_unit, test_privacy_add)
{
helper_privacy_add(0);
}
-void test_privacy_add_stress(void)
+ZTEST(test_ctrl_sw_privacy_unit, test_privacy_add_stress)
{
bt_addr_t ar;
@@ -107,12 +115,3 @@
prpa_cache_clear();
}
}
-
-void test_main(void)
-{
- ztest_test_suite(test, ztest_unit_test(test_privacy_clear),
- ztest_unit_test(test_privacy_add),
- ztest_unit_test(test_privacy_clear),
- ztest_unit_test(test_privacy_add_stress));
- ztest_run_test_suite(test);
-}