tests: Bluetooth: df: set conn cte tx params migrate to new ZTEST API
Migrate tests in connection_cte_tx_params to new ZTEST API.
Remove main.c source file because is unncessary when automatic
unit tests registration is available.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
diff --git a/tests/bluetooth/df/connection_cte_tx_params/prj.conf b/tests/bluetooth/df/connection_cte_tx_params/prj.conf
index c6cca86..3dcda14 100644
--- a/tests/bluetooth/df/connection_cte_tx_params/prj.conf
+++ b/tests/bluetooth/df/connection_cte_tx_params/prj.conf
@@ -1,5 +1,6 @@
CONFIG_TEST=y
CONFIG_ZTEST=y
+CONFIG_ZTEST_NEW_API=y
CONFIG_BT=y
# It does not matter for the test whether central or peripheral is used.
diff --git a/tests/bluetooth/df/connection_cte_tx_params/src/main.c b/tests/bluetooth/df/connection_cte_tx_params/src/main.c
deleted file mode 100644
index 4512d71..0000000
--- a/tests/bluetooth/df/connection_cte_tx_params/src/main.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2021 Nordic Semiconductor ASA
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <bt_common.h>
-
-#include "test_set_conn_cte_tx_params.h"
-
-/*test case main entry*/
-void test_main(void)
-{
- ut_bt_setup();
-
- run_set_conn_cte_tx_params_tests();
-}
diff --git a/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.c b/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.c
index 017786d..f00627e 100644
--- a/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.c
+++ b/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.c
@@ -13,8 +13,8 @@
#include <zephyr/sys/byteorder.h>
#include <host/hci_core.h>
+#include <bt_common.h>
#include <bt_conn_common.h>
-#include "test_set_conn_cte_tx_params.h"
static uint16_t g_conn_handle;
@@ -81,7 +81,7 @@
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, buf, NULL);
}
-void test_set_conn_cte_tx_params_with_invalid_conn_handle(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_invalid_conn_handle)
{
int err;
@@ -90,7 +90,7 @@
"Unexpected error value for set conn CTE tx params with wrong conn handle");
}
-void test_set_conn_cte_tx_params_with_cte_type_none(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_cte_type_none)
{
int err;
@@ -102,7 +102,7 @@
"durations");
}
-void test_set_conn_cte_tx_params_with_cte_type_invalid(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_cte_type_invalid)
{
int err;
@@ -114,7 +114,7 @@
"durations");
}
-void test_set_conn_cte_tx_params_with_too_long_switch_pattern_len(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_too_long_switch_pattern_len)
{
int err;
uint8_t ant_ids[SWITCH_PATTERN_LEN_TOO_LONG] = { 0 };
@@ -128,7 +128,7 @@
"length beyond max value");
}
-void test_set_conn_cte_tx_params_with_too_short_switch_pattern_len(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_too_short_switch_pattern_len)
{
int err;
uint8_t ant_ids[SWITCH_PATTERN_LEN_TOO_SHORT] = { 0 };
@@ -142,7 +142,7 @@
"length below min value");
}
-void test_set_conn_cte_tx_params_with_ant_ids_ptr_null(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_ant_ids_ptr_null)
{
int err;
@@ -158,7 +158,7 @@
"pointing NULL");
}
-void test_set_conn_cte_tx_params_with_correct_params(void)
+ZTEST(test_set_conn_cte_tx_params, test_set_conn_cte_tx_params_with_correct_params)
{
int err;
@@ -168,7 +168,7 @@
"params");
}
-static void connection_setup(void)
+static void connection_setup(void *data)
{
g_params.cte_types =
BT_HCI_LE_AOA_CTE_RSP | BT_HCI_LE_AOD_CTE_RSP_1US | BT_HCI_LE_AOD_CTE_RSP_2US;
@@ -178,29 +178,7 @@
g_conn_handle = ut_bt_create_connection();
}
-static void connection_teardown(void)
-{
- ut_bt_destroy_connection(g_conn_handle);
-}
+static void connection_teardown(void *data) { ut_bt_destroy_connection(g_conn_handle); }
-void run_set_conn_cte_tx_params_tests(void)
-{
- ztest_test_suite(
- test_set_conn_cte_tx_params,
- ztest_unit_test(test_set_conn_cte_tx_params_with_invalid_conn_handle),
- ztest_unit_test_setup_teardown(test_set_conn_cte_tx_params_with_cte_type_none,
- connection_setup, connection_teardown),
- ztest_unit_test_setup_teardown(test_set_conn_cte_tx_params_with_cte_type_invalid,
- connection_setup, connection_teardown),
- ztest_unit_test_setup_teardown(
- test_set_conn_cte_tx_params_with_too_long_switch_pattern_len,
- connection_setup, connection_teardown),
- ztest_unit_test_setup_teardown(
- test_set_conn_cte_tx_params_with_too_short_switch_pattern_len,
- connection_setup, connection_teardown),
- ztest_unit_test_setup_teardown(test_set_conn_cte_tx_params_with_ant_ids_ptr_null,
- connection_setup, connection_teardown),
- ztest_unit_test_setup_teardown(test_set_conn_cte_tx_params_with_correct_params,
- connection_setup, connection_teardown));
- ztest_run_test_suite(test_set_conn_cte_tx_params);
-}
+ZTEST_SUITE(test_set_conn_cte_tx_params, NULL, ut_bt_setup, connection_setup, connection_teardown,
+ ut_bt_teardown);
diff --git a/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.h b/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.h
deleted file mode 100644
index 5bb8131..0000000
--- a/tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright (c) 2021 Nordic Semiconductor ASA
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/* Runs tests for HCI_LE_Set_Connection_CTE_Transmit_Parameters command */
-void run_set_conn_cte_tx_params_tests(void);