tests: drivers: watchdog: wdt_error_cases: Add test scenario
Add test scenario that verifies correct error code returned by wdt_setup() when called just after wdt_disable(). Scenario: - configure WDT timeout; - start WDT by calling wdt_setup(); - remove all WDT timeouts by calling wdt_disable(); - confirm wdt_setup() returns error code due to lack of configured WDT timeouts. Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
This commit is contained in:
parent
319a8867ef
commit
4041a2507d
1 changed files with 42 additions and 0 deletions
|
@ -776,6 +776,48 @@ ZTEST(wdt_coverage, test_08d_wdt_disable_check_timeouts_uninstalled)
|
|||
zassert_equal(m_test_08d_B_value, 0, "Timeout B has fired while it shouldn't");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test error code when wdt_setup() is called after wdt_disable()
|
||||
*
|
||||
* Confirm that wdt_setup() returns error value or ASSERTION FAIL
|
||||
* when it's called before any timeout was configured with wdt_install_timeouts().
|
||||
* All timeouts were uninstalled by calling wdt_disable().
|
||||
*
|
||||
*/
|
||||
ZTEST(wdt_coverage, test_08e_wdt_setup_immediately_after_wdt_disable)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!(WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED)) {
|
||||
/* Skip this test because wdt_disable() is NOT supported. */
|
||||
ztest_test_skip();
|
||||
}
|
||||
|
||||
m_cfg_wdt0.callback = NULL;
|
||||
m_cfg_wdt0.flags = DEFAULT_FLAGS;
|
||||
m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX;
|
||||
m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN;
|
||||
|
||||
ret = wdt_install_timeout(wdt, &m_cfg_wdt0);
|
||||
zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret);
|
||||
TC_PRINT("Configured WDT channel %d\n", ret);
|
||||
|
||||
ret = wdt_setup(wdt, DEFAULT_OPTIONS);
|
||||
zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret);
|
||||
|
||||
ret = wdt_disable(wdt);
|
||||
zassert_true(ret == 0, "Watchdog disable error, got unexpected value of %d", ret);
|
||||
|
||||
/* Call wdt_setup when no timeouts are configured. */
|
||||
/* Timeouts were removed by calling wdt_disable(). */
|
||||
ztest_set_assert_valid(true);
|
||||
ret = wdt_setup(wdt, DEFAULT_OPTIONS);
|
||||
zassert_true(ret < 0,
|
||||
"Calling wdt_setup before installing timeouts should fail, got unexpected "
|
||||
"value of %d",
|
||||
ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief wdt_feed() negative test
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue