tests: nrf_onof_and_bt: move to new ztest API

test cases in tests/drivers/clock_control/nrf_onoff_and_bt are moved
to new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
This commit is contained in:
Meng xianglin 2022-07-08 13:44:28 +08:00 committed by Fabio Baltieri
commit 22d62cf28d
2 changed files with 6 additions and 19 deletions

View file

@ -1,2 +1,3 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_ENTROPY_GENERATOR=y

View file

@ -24,8 +24,9 @@ static const struct device *const entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entro
static struct onoff_manager *hf_mgr;
static uint32_t iteration;
static void setup(void)
static void before(void *data)
{
ARG_UNUSED(data);
zassert_true(device_is_ready(entropy), NULL);
hf_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
@ -34,11 +35,6 @@ static void setup(void)
iteration = 0;
}
static void teardown(void)
{
/* empty */
}
static void bt_timeout_handler(struct k_timer *timer)
{
static bool on;
@ -100,7 +96,7 @@ static void check_hf_status(const struct device *dev, bool exp_on,
* Test runs in the loop to eventually lead to cases when clock controlling is
* preempted by timeout handler. At certain points clock status is validated.
*/
static void test_onoff_interrupted(void)
ZTEST(nrf_onoff_and_bt, test_onoff_interrupted)
{
const struct device *const clock_dev = DEVICE_DT_GET_ONE(nordic_nrf_clock);
struct onoff_client cli;
@ -194,7 +190,7 @@ K_TIMER_DEFINE(timer2, onoff_timeout_handler, NULL);
* Test runs in the loop to eventually lead to cases when clock controlling is
* preempted by timeout handler. At certain points clock status is validated.
*/
static void test_bt_interrupted(void)
ZTEST(nrf_onoff_and_bt, test_bt_interrupted)
{
const struct device *const clock_dev = DEVICE_DT_GET_ONE(nordic_nrf_clock);
uint64_t start_time = k_uptime_get();
@ -240,14 +236,4 @@ static void test_bt_interrupted(void)
k_msleep(100);
check_hf_status(clock_dev, false, true);
}
void test_main(void)
{
ztest_test_suite(test_nrf_onoff_and_bt,
ztest_unit_test_setup_teardown(test_onoff_interrupted,
setup, teardown),
ztest_unit_test_setup_teardown(test_bt_interrupted,
setup, teardown)
);
ztest_run_test_suite(test_nrf_onoff_and_bt);
}
ZTEST_SUITE(nrf_onoff_and_bt, NULL, NULL, before, NULL, NULL);