Skip to content

Commit 0c4f198

Browse files
nandojvekartben
authored andcommitted
tests: watchdog: Add missing wdt_disable in API test
The current watchdog tests assume that watchdog can be configured once it is running. This is a concept that do not work in practice becasue most of watchdog once configured will be locked. The tests should take that in consideration before enable another test. The other important details is that even when a watchdog is running it should be disable in some controllers to allow reconfigure. This change was tested with SAM4L watchdog controller #83475 which allows reconfigure the watchdog once it is enabled. To do the correct configuration it is necessary execute the wdt_disable() call. The change will validate if the watchdog can be disabled for those cases were the controller is not locked and fallback the test on the contrary. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
1 parent ad4ed55 commit 0c4f198

File tree

1 file changed

+17
-0
lines changed
  • tests/drivers/watchdog/wdt_basic_api/src

1 file changed

+17
-0
lines changed

tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ static int test_wdt_callback_1(void)
257257
}
258258
}
259259

260+
err = wdt_disable(wdt);
261+
if (err < 0 && err != -EPERM && err != -EFAULT) {
262+
TC_PRINT("Watchdog disable error\n");
263+
return TC_FAIL;
264+
}
265+
260266
m_testvalue = 0U;
261267
m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC;
262268
m_cfg_wdt0.callback = wdt_int_cb0;
@@ -316,6 +322,11 @@ static int test_wdt_callback_2(void)
316322
}
317323
}
318324

325+
err = wdt_disable(wdt);
326+
if (err < 0 && err != -EPERM && err != -EFAULT) {
327+
TC_PRINT("Watchdog disable error\n");
328+
return TC_FAIL;
329+
}
319330

320331
m_testvalue = 0U;
321332
m_cfg_wdt0.callback = wdt_int_cb0;
@@ -370,6 +381,12 @@ static int test_wdt_bad_window_max(void)
370381

371382
TC_PRINT("Testcase: %s\n", __func__);
372383

384+
err = wdt_disable(wdt);
385+
if (err < 0 && err != -EPERM && err != -EFAULT) {
386+
TC_PRINT("Watchdog disable error\n");
387+
return TC_FAIL;
388+
}
389+
373390
m_cfg_wdt0.callback = NULL;
374391
m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC;
375392
m_cfg_wdt0.window.max = 0U;

0 commit comments

Comments
 (0)