Skip to content

Commit 0469cef

Browse files
committed
tests: drivers: watchdog: use Kconfig options for setup flags and timeout
Replace hard-coded platform definrs with Kconfig marcos Signed-off-by: Quy Tran <[email protected]>
1 parent 42bc460 commit 0469cef

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

tests/drivers/watchdog/wdt_basic_reset_none/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,15 @@ config TEST_WDT_SLEEP_TIME
2020
The units for this value will change based on the watchdog
2121
driver being tested. Most drivers represent this as milliseconds
2222
due to the max window reaching the millisecond feed window.
23+
24+
config TEST_WDT_SETUP_FLAGS
25+
int "WDT setup flags for test, selectable options are: No flags (0x0U), WDT_OPT_PAUSE_IN_SLEEP (0x1U), WDT_OPT_PAUSE_HALTED_BY_DBG (0x2U)"
26+
default 2
27+
help
28+
Set the watchdog setup flags for the test.
29+
30+
config TEST_WDT_TIMEOUT_UNIT_TICKS
31+
bool "Use watchdog timeout unit in ticks"
32+
default n
33+
help
34+
Enable this option to configure the watchdog timeout unit in system ticks
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST_WDT_SETUP_FLAGS=0
2+
CONFIG_TEST_WDT_TIMEOUT_UNIT_TICKS=y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_TEST_WDT_SETUP_FLAGS=0

tests/drivers/watchdog/wdt_basic_reset_none/src/main.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <zephyr/ztest.h>
88
#include <zephyr/drivers/watchdog.h>
99

10-
1110
/*
1211
* To use this test, either the devicetree's /aliases must have a
1312
* 'watchdog0' property, or one of the following watchdog compatibles
@@ -19,18 +18,17 @@
1918
#define WDT_NODE DT_INST(0, nxp_s32_swt)
2019
#endif
2120

22-
#define WDT_FEED_TRIES 2
23-
#define WDT_TEST_CB_TEST_VALUE 0xCB
24-
#define WDT_TIMEOUT_VALUE CONFIG_TEST_WDT_MAX_WINDOW_TIME + 10
21+
#define WDT_FEED_TRIES 2
22+
#define WDT_TEST_CB_TEST_VALUE 0xCB
23+
#define WDT_TIMEOUT_VALUE CONFIG_TEST_WDT_MAX_WINDOW_TIME + 10
24+
#define WDT_SETUP_FLAGS CONFIG_TEST_WDT_SETUP_FLAGS
2525

26-
#if defined(CONFIG_WDT_NXP_EWM)
27-
#define WDT_SETUP_FLAGS 0
28-
#define WDT_TIMEOUT K_TICKS(WDT_TIMEOUT_VALUE)
29-
#define SLEEP_TIME K_TICKS(CONFIG_TEST_WDT_SLEEP_TIME)
26+
#if defined(CONFIG_TEST_WDT_TIMEOUT_UNIT_TICKS)
27+
#define WDT_TIMEOUT K_TICKS(WDT_TIMEOUT_VALUE)
28+
#define SLEEP_TIME K_TICKS(CONFIG_TEST_WDT_SLEEP_TIME)
3029
#else
31-
#define WDT_SETUP_FLAGS WDT_OPT_PAUSE_HALTED_BY_DBG
32-
#define WDT_TIMEOUT K_MSEC(WDT_TIMEOUT_VALUE)
33-
#define SLEEP_TIME K_MSEC(CONFIG_TEST_WDT_SLEEP_TIME)
30+
#define WDT_TIMEOUT K_MSEC(WDT_TIMEOUT_VALUE)
31+
#define SLEEP_TIME K_MSEC(CONFIG_TEST_WDT_SLEEP_TIME)
3432
#endif
3533

3634
static struct wdt_timeout_cfg m_cfg_wdt0;
@@ -41,9 +39,8 @@ static volatile int wdt_feed_flag;
4139
static void wdt_callback(const struct device *dev, int channel_id)
4240
{
4341
wdt_interrupted_flag += WDT_TEST_CB_TEST_VALUE;
44-
zassert_equal(WDT_FEED_TRIES, wdt_feed_flag,
45-
"%d: Invalid number of feeding (expected: %d)",
46-
wdt_feed_flag, WDT_FEED_TRIES);
42+
zassert_equal(WDT_FEED_TRIES, wdt_feed_flag, "%d: Invalid number of feeding (expected: %d)",
43+
wdt_feed_flag, WDT_FEED_TRIES);
4744
}
4845

4946
static int test_wdt_callback_reset_none(void)
@@ -80,7 +77,7 @@ static int test_wdt_callback_reset_none(void)
8077
wdt_feed_flag = 0;
8178
wdt_interrupted_flag = 0;
8279
for (int i = 0; i < WDT_FEED_TRIES; ++i) {
83-
TC_PRINT("Feeding %d\n", i+1);
80+
TC_PRINT("Feeding %d\n", i + 1);
8481
wdt_feed(wdt, 0);
8582
wdt_feed_flag++;
8683
k_sleep(SLEEP_TIME);
@@ -95,8 +92,7 @@ static int test_wdt_callback_reset_none(void)
9592
}
9693
}
9794

98-
zassert_equal(wdt_interrupted_flag, WDT_TEST_CB_TEST_VALUE,
99-
"wdt callback failed");
95+
zassert_equal(wdt_interrupted_flag, WDT_TEST_CB_TEST_VALUE, "wdt callback failed");
10096

10197
err = wdt_disable(wdt);
10298
if (err == -EPERM) {
@@ -132,7 +128,6 @@ static int test_wdt_bad_window_max(void)
132128
return TC_FAIL;
133129
}
134130

135-
136131
ZTEST(wdt_basic_reset_none, test_wdt_callback_reset_none)
137132
{
138133
switch (test_wdt_callback_reset_none()) {

tests/drivers/watchdog/wdt_basic_reset_none/testcase.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ tests:
2727
- frdm_mcxw72/mcxw727c/cpu0
2828
- mimxrt1180_evk/mimxrt1189/cm33
2929
- mimxrt1180_evk/mimxrt1189/cm7
30-
extra_args: DTC_OVERLAY_FILE="boards/app_ewm.overlay"
30+
extra_args:
31+
- EXTRA_CONF_FILE="boards/app_ewm.conf"
32+
- DTC_OVERLAY_FILE="boards/app_ewm.overlay"
3133
extra_configs:
3234
- CONFIG_TEST_WDT_MAX_WINDOW_TIME=254
3335
- CONFIG_TEST_WDT_SLEEP_TIME=68
@@ -37,7 +39,9 @@ tests:
3739
- frdm_ke17z
3840
integration_platforms:
3941
- frdm_ke17z
40-
extra_args: DTC_OVERLAY_FILE="boards/frdm_ke1xz.overlay"
42+
extra_args:
43+
- EXTRA_CONF_FILE="boards/app_ewm.conf"
44+
- DTC_OVERLAY_FILE="boards/frdm_ke1xz.overlay"
4145
extra_configs:
4246
- CONFIG_TEST_WDT_MAX_WINDOW_TIME=254
4347
- CONFIG_TEST_WDT_SLEEP_TIME=68

0 commit comments

Comments
 (0)