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
16 changes: 15 additions & 1 deletion tests/drivers/pwm/pwm_loopback/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@ static void *pwm_loopback_setup(void)
return NULL;
}

ZTEST_SUITE(pwm_loopback, NULL, pwm_loopback_setup, NULL, NULL, NULL);
static void pwm_loopback_after(void *f)
{
struct test_pwm in;
struct test_pwm out;
int err;

ARG_UNUSED(f);

get_test_pwms(&out, &in);

err = pwm_disable_capture(in.dev, in.pwm);
zassert_equal(err, 0, "failed to disable pwm capture (err %d)", err);
}

ZTEST_SUITE(pwm_loopback, NULL, pwm_loopback_setup, NULL, pwm_loopback_after, NULL);
9 changes: 7 additions & 2 deletions tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
ztest_test_fail();
}

pwm_disable_capture(in.dev, in.pwm);

if (err == -ENOTSUP) {
TC_PRINT("capture type not supported\n");
ztest_test_skip();
Expand All @@ -97,10 +99,13 @@
"period capture off by more than 1%");
}

if (flags & PWM_CAPTURE_TYPE_PULSE) {
if (flags & PWM_POLARITY_INVERTED) {
zassert_within(pulse_capture, period - pulse, (period - pulse) / 100,
"pulse capture off by more than 1%");
} else {
zassert_within(pulse_capture, pulse, pulse / 100,
"pulse capture off by more than 1%");
"pulse capture off by more than 1%");
}

Check notice on line 108 in tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/drivers/pwm/pwm_loopback/src/test_pwm_loopback.c:108 - "pulse capture off by more than 1%"); + "pulse capture off by more than 1%"); } else { zassert_within(pulse_capture, pulse, pulse / 100, - "pulse capture off by more than 1%"); + "pulse capture off by more than 1%");
}

ZTEST_USER(pwm_loopback, test_pulse_capture)
Expand Down
Loading