Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/drivers/pwm/pwm_api/prj.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_PWM=y
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_TEST_USERSPACE=y
11 changes: 4 additions & 7 deletions tests/drivers/pwm/pwm_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
#include <zephyr/device.h>

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);
4 changes: 2 additions & 2 deletions tests/drivers/pwm/pwm_api/src/test_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/drivers/pwm/pwm_loopback/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_TEST_USERSPACE=y

CONFIG_PWM=y
Expand Down
15 changes: 4 additions & 11 deletions tests/drivers/pwm/pwm_loopback/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
18 changes: 9 additions & 9 deletions tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 0 additions & 16 deletions tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */