tests: pwm_loopback: Capture disable omission issue
As per the PWM API definition, -EBUSY should be returned when pwm_enable_capture is called and capturing is already enabled. This commit deals with adding a ztest_suite_before_t function that should disable capturing at the end of a single test. Some tests, though, such as test_pulse_capture, execute two sub-tests and so, capturing is disabled in between. In fact, the omission of pwm_disable_capture should not only result in aborting a single test, but it can also raise system exception due to invalid context. This is the case for z_impl_pwm_capture_cycles where z_pwm_capture_cycles_callback can be fired whilst the routine has already aborted and so struct z_pwm_capture_cb_data data, defined within function declaration, should not longer be valid. Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
This commit is contained in:
parent
007350a9c9
commit
b1e863e3e7
2 changed files with 17 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -85,6 +85,8 @@ static void test_capture(uint32_t period, uint32_t pulse, enum test_pwm_unit uni
|
|||
ztest_test_fail();
|
||||
}
|
||||
|
||||
pwm_disable_capture(in.dev, in.pwm);
|
||||
|
||||
if (err == -ENOTSUP) {
|
||||
TC_PRINT("capture type not supported\n");
|
||||
ztest_test_skip();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue