1This test suite contains negative test cases for the Watchdog driver.
2Test scenarios validate that invalid use of the watchdog driver
3returns error code as described in the API documentation
4(or Assertion Fail as explained below).
5
6Ideally, the driver shall be fully compliant with the documentation.
7However, it may happen that invalid function call results in
8Assertion Fail instead of error code.
9Since, main goal is to detect (and report) invalid use of the driver,
10both error code and assertion fail set test result as passed.
11See for example test_02_wdt_setup_before_setting_timeouts where
12ztest_set_assert_valid(true);
13is used to catch assertion fail.
14
15These tests were written to increase test coverage for the Watchdog driver.
16Since, coverage data is stored in the RAM, it is lost when watchdog fires.
17Therefore, in all test cases watchdog shall NOT expire.
18Use other sample to verify positive scenario for the watchdog driver.
19
20These tests were prepared on a target that had a bug in the wdt_disable()
21implementation. As a temporary remedy, order of tests was imposed.
22Since, tests are executed alphabetically, order was set by starting
23each test name with f.e. 'test_08b_...'.
24
25
26Tests are based on the watchdog API documentation available here:
27https://docs.zephyrproject.org/latest/hardware/peripherals/watchdog.html
28
29
30Follow these guidelines when enabling test execution on a new target.
31
321. Although, code defines WDT_DISABLE_SUPPORTED but it was tested on a
33   target that supports disabling the watchdog.
34   Multiple tests call wdt_setup() which starts the watchdog.
35   Every test assumes that watchdog is disabled at startup.
36   As a result, executing this test suite on a target that doesn't
37   support wdt_disable() may require changes to the code.
38   When target supports wdt_disable() then extend WDT_TEST_FLAGS with:
39   #define WDT_TEST_FLAGS (... | WDT_DISABLE_SUPPORTED)
40
412. There are three watchdog flags that can be passed to wdt_install_timeout():
42    - WDT_FLAG_RESET_NONE - when watchdog expires, it's callback is serviced but
43      reset doesn't occur.
44    - WDT_FLAG_RESET_CPU_CORE - when watchdog expires, only one core is reset, while
45      other cores are not affected.
46    - WDT_FLAG_RESET_SOC - when watchdog expires, target as "a whole" is reset.
47   Support for these flags varies between vendors and products.
48   a) List all supported flags in
49      #define WDT_TEST_FLAGS (... | WDT_FLAG_RESET_NONE_SUPPORTED |
50                              WDT_FLAG_RESET_CPU_CORE_SUPPORTED |
51                              WDT_FLAG_RESET_SOC_SUPPORTED)
52   b) Set supported flag in
53      #define DEFAULT_FLAGS (WDT_FLAG_RESET_SOC)
54      This define will be used in wdt_install_timeout() "correct" test step.
55
563. These tests assume that watchdog driver supports multiple timeouts. Set
57   #define MAX_INSTALLABLE_TIMEOUTS (8)
58
594. When all watchdog timeouts must have exactly the same watchdog timeout value
60   then extend WDT_TEST_FLAGS with:
61   #define WDT_TEST_FLAGS (... | WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED)
62
635. Set maximal allowed watchdog timeout value, f.e.:
64   #define WDT_WINDOW_MAX_ALLOWED (0xFFFFFFFFU)
65   Also, test assumes that minimal allowed watchdog timeout value must be zero.
66
676. There are two watchdog options that can be passed to wdt_setup():
68    - WDT_OPT_PAUSE_IN_SLEEP;
69    - WDT_OPT_PAUSE_HALTED_BY_DBG.
70   Support for these options varies between vendors and products.
71   a) List all supported options in
72      #define WDT_TEST_FLAGS (... | WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED |
73                              WDT_OPT_PAUSE_HALTED_BY_DBG_SUPPORTED)
74   b) Set supported option(s) in
75      #define DEFAULT_OPTIONS (WDT_OPT_PAUSE_IN_SLEEP | WDT_OPT_PAUSE_HALTED_BY_DBG)
76      This define will be used in wdt_setup() "correct" test step.
77
787. When wdt_feed() can stall, extend WDT_TEST_FLAGS with:
79   #define WDT_TEST_FLAGS (... | WDT_FEED_CAN_STALL)
80