diff --git a/tests/drivers/pwm/pwm_api/prj.conf b/tests/drivers/pwm/pwm_api/prj.conf index 21d92de3cb47f..7375a2bd0b432 100644 --- a/tests/drivers/pwm/pwm_api/prj.conf +++ b/tests/drivers/pwm/pwm_api/prj.conf @@ -1,3 +1,4 @@ CONFIG_PWM=y CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y CONFIG_TEST_USERSPACE=y diff --git a/tests/drivers/pwm/pwm_api/src/main.c b/tests/drivers/pwm/pwm_api/src/main.c index 4d56ffae3da9b..65d085417cc5e 100644 --- a/tests/drivers/pwm/pwm_api/src/main.c +++ b/tests/drivers/pwm/pwm_api/src/main.c @@ -10,18 +10,15 @@ #include const struct device *get_pwm_device(void); -void test_pwm_cycle(void); -void test_pwm_nsec(void); -void test_main(void) +static void *pwm_basic_setup(void) { const struct device *dev = get_pwm_device(); zassert_true(device_is_ready(dev), "PWM device is not ready"); k_object_access_grant(dev, k_current_get()); - ztest_test_suite(pwm_basic_test, - ztest_user_unit_test(test_pwm_nsec), - ztest_user_unit_test(test_pwm_cycle)); - ztest_run_test_suite(pwm_basic_test); + return NULL; } + +ZTEST_SUITE(pwm_basic, NULL, pwm_basic_setup, NULL, NULL, NULL); diff --git a/tests/drivers/pwm/pwm_api/src/test_pwm.c b/tests/drivers/pwm/pwm_api/src/test_pwm.c index 23027752e1e68..8039caa6ea3e8 100644 --- a/tests/drivers/pwm/pwm_api/src/test_pwm.c +++ b/tests/drivers/pwm/pwm_api/src/test_pwm.c @@ -126,7 +126,7 @@ static int test_task(uint32_t port, uint32_t period, uint32_t pulse, uint8_t uni return TC_PASS; } -void test_pwm_nsec(void) +ZTEST_USER(pwm_basic, test_pwm_nsec) { /* Period : Pulse (2000000 : 1000000), unit (nsec). Voltage : 1.65V */ zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_NSEC, @@ -144,7 +144,7 @@ void test_pwm_nsec(void) k_sleep(K_MSEC(1000)); } -void test_pwm_cycle(void) +ZTEST_USER(pwm_basic, test_pwm_cycle) { /* Period : Pulse (64000 : 32000), unit (cycle). Voltage : 1.65V */ zassert_true(test_task(DEFAULT_PWM_PORT, DEFAULT_PERIOD_CYCLE, diff --git a/tests/drivers/pwm/pwm_loopback/prj.conf b/tests/drivers/pwm/pwm_loopback/prj.conf index 73f7ae3cd455b..3d01d55ecb817 100644 --- a/tests/drivers/pwm/pwm_loopback/prj.conf +++ b/tests/drivers/pwm/pwm_loopback/prj.conf @@ -1,4 +1,5 @@ CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y CONFIG_TEST_USERSPACE=y CONFIG_PWM=y diff --git a/tests/drivers/pwm/pwm_loopback/src/main.c b/tests/drivers/pwm/pwm_loopback/src/main.c index 149b9bc0b9a1a..e3ccec475633e 100644 --- a/tests/drivers/pwm/pwm_loopback/src/main.c +++ b/tests/drivers/pwm/pwm_loopback/src/main.c @@ -9,7 +9,7 @@ #include "test_pwm_loopback.h" -void test_main(void) +static void *pwm_loopback_setup(void) { struct test_pwm in; struct test_pwm out; @@ -19,14 +19,7 @@ void test_main(void) k_object_access_grant(out.dev, k_current_get()); k_object_access_grant(in.dev, k_current_get()); - ztest_test_suite(pwm_loopback_test, - ztest_user_unit_test(test_pulse_capture), - ztest_user_unit_test(test_pulse_capture_inverted), - ztest_user_unit_test(test_period_capture), - ztest_user_unit_test(test_period_capture_inverted), - ztest_user_unit_test(test_pulse_and_period_capture), - ztest_user_unit_test(test_capture_timeout), - ztest_unit_test(test_continuous_capture), - ztest_unit_test(test_capture_busy)); - ztest_run_test_suite(pwm_loopback_test); + return NULL; } + +ZTEST_SUITE(pwm_loopback, NULL, pwm_loopback_setup, NULL, NULL, NULL); diff --git a/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c b/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c index 6d2c226021bea..42aed09141894 100644 --- a/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c +++ b/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c @@ -35,7 +35,7 @@ void get_test_pwms(struct test_pwm *out, struct test_pwm *in) zassert_true(device_is_ready(in->dev), "pwm loopback input device is not ready"); } -void test_capture(uint32_t period, uint32_t pulse, enum test_pwm_unit unit, +static void test_capture(uint32_t period, uint32_t pulse, enum test_pwm_unit unit, pwm_flags_t flags) { struct test_pwm in; @@ -103,7 +103,7 @@ void test_capture(uint32_t period, uint32_t pulse, enum test_pwm_unit unit, } } -void test_pulse_capture(void) +ZTEST_USER(pwm_loopback, test_pulse_capture) { test_capture(TEST_PWM_PERIOD_NSEC, TEST_PWM_PULSE_NSEC, TEST_PWM_UNIT_NSEC, @@ -113,7 +113,7 @@ void test_pulse_capture(void) PWM_CAPTURE_TYPE_PULSE | PWM_POLARITY_NORMAL); } -void test_pulse_capture_inverted(void) +ZTEST_USER(pwm_loopback, test_pulse_capture_inverted) { test_capture(TEST_PWM_PERIOD_NSEC, TEST_PWM_PULSE_NSEC, TEST_PWM_UNIT_NSEC, @@ -123,7 +123,7 @@ void test_pulse_capture_inverted(void) PWM_CAPTURE_TYPE_PULSE | PWM_POLARITY_INVERTED); } -void test_period_capture(void) +ZTEST_USER(pwm_loopback, test_period_capture) { test_capture(TEST_PWM_PERIOD_NSEC, TEST_PWM_PULSE_NSEC, TEST_PWM_UNIT_NSEC, @@ -133,7 +133,7 @@ void test_period_capture(void) PWM_CAPTURE_TYPE_PERIOD | PWM_POLARITY_NORMAL); } -void test_period_capture_inverted(void) +ZTEST_USER(pwm_loopback, test_period_capture_inverted) { test_capture(TEST_PWM_PERIOD_NSEC, TEST_PWM_PULSE_NSEC, TEST_PWM_UNIT_NSEC, @@ -143,7 +143,7 @@ void test_period_capture_inverted(void) PWM_CAPTURE_TYPE_PERIOD | PWM_POLARITY_INVERTED); } -void test_pulse_and_period_capture(void) +ZTEST_USER(pwm_loopback, test_pulse_and_period_capture) { test_capture(TEST_PWM_PERIOD_NSEC, TEST_PWM_PULSE_NSEC, TEST_PWM_UNIT_NSEC, @@ -153,7 +153,7 @@ void test_pulse_and_period_capture(void) PWM_CAPTURE_TYPE_BOTH | PWM_POLARITY_NORMAL); } -void test_capture_timeout(void) +ZTEST_USER(pwm_loopback, test_capture_timeout) { struct test_pwm in; struct test_pwm out; @@ -212,7 +212,7 @@ static void continuous_capture_callback(const struct device *dev, } } -void test_continuous_capture(void) +ZTEST(pwm_loopback, test_continuous_capture) { struct test_pwm in; struct test_pwm out; @@ -278,7 +278,7 @@ void test_continuous_capture(void) } } -void test_capture_busy(void) +ZTEST(pwm_loopback, test_capture_busy) { struct test_pwm in; struct test_pwm out; diff --git a/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.h b/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.h index 062f953b6f20e..adab339cb10cc 100644 --- a/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.h +++ b/tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.h @@ -47,20 +47,4 @@ struct test_pwm_callback_data { void get_test_pwms(struct test_pwm *out, struct test_pwm *in); -void test_pulse_capture(void); - -void test_pulse_capture_inverted(void); - -void test_period_capture(void); - -void test_period_capture_inverted(void); - -void test_pulse_and_period_capture(void); - -void test_capture_timeout(void); - -void test_continuous_capture(void); - -void test_capture_busy(void); - #endif /* __TEST_PWM_LOOPBACK_H__ */