diff --git a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c index 4c68650ef1d..c8b6620d069 100644 --- a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c +++ b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c @@ -62,14 +62,34 @@ #include #include "test_wdt.h" -#ifdef DT_ALIAS_WATCHDOG0_LABEL -#define WDT_DEV_NAME DT_ALIAS_WATCHDOG0_LABEL -#else -#ifdef CONFIG_WWDG_STM32 -#define WDT_DEV_NAME DT_LABEL(DT_INST(0, st_stm32_window_watchdog)) -#else -#define WDT_DEV_NAME DT_WDT_0_NAME +/* + * To use this test, either the devicetree's /aliases must have a + * 'watchdog0' property, or one of the following watchdog compatibles + * must have an enabled node. + */ +#if DT_HAS_NODE(DT_ALIAS(watchdog0)) +#define WDT_NODE DT_ALIAS(watchdog0) +#elif DT_HAS_COMPAT(st_stm32_window_watchdog) +#define WDT_NODE DT_INST(0, st_stm32_window_watchdog) +#elif DT_HAS_COMPAT(st_stm32_watchdog) +#define WDT_NODE DT_INST(0, st_stm32_watchdog) +#elif DT_HAS_COMPAT(nordic_nrf_watchdog) +#define WDT_NODE DT_INST(0, nordic_nrf_watchdog) +#elif DT_HAS_COMPAT(espressif_esp32_watchdog) +#define WDT_NODE DT_INST(0, espressif_esp32_watchdog) +#elif DT_HAS_COMPAT(silabs_gecko_wdog) +#define WDT_NODE DT_INST(0, silabs_gecko_wdog) +#elif DT_HAS_COMPAT(nxp_kinetis_wdog32) +#define WDT_NODE DT_INST(0, nxp_kinetis_wdog32) +#elif DT_HAS_COMPAT(microchip_xec_watchdog) +#define WDT_NODE DT_INST(0, microchip_xec_watchdog) #endif + +#ifdef WDT_NODE +#define WDT_DEV_NAME DT_LABEL(WDT_NODE) +#else +#define WDT_DEV_NAME "" +#error "Unsupported SoC and no watchdog0 alias in zephyr.dts" #endif #define WDT_TEST_STATE_IDLE 0