@@ -400,9 +400,74 @@ static int test_wdt_bad_window_max(void)
400
400
return TC_FAIL ;
401
401
}
402
402
403
+ static int test_wdt_enable_wait_mode (void )
404
+ {
405
+ #ifndef CONFIG_PM
406
+ TC_PRINT ("Testcase: %s\n" , __func__ );
407
+ ztest_test_skip ();
408
+ m_state = WDT_TEST_STATE_IDLE ;
409
+ return TC_SKIP ;
410
+ #else
411
+ int err ;
412
+ int wdt_channel_id ;
413
+ const struct device * const wdt = DEVICE_DT_GET (WDT_NODE );
414
+
415
+ if (!device_is_ready (wdt )) {
416
+ TC_PRINT ("WDT device is not ready\n" );
417
+ return TC_FAIL ;
418
+ }
419
+
420
+ TC_PRINT ("Testcase: %s\n" , __func__ );
421
+
422
+ if (m_state == WDT_TEST_STATE_CHECK_RESET ) {
423
+ m_state = WDT_TEST_STATE_IDLE ;
424
+ TC_PRINT ("Testcase passed\n" );
425
+ return TC_PASS ;
426
+ }
427
+
428
+ struct wdt_timeout_cfg wdt_config = {
429
+ /* Reset SoC when watchdog timer expires. */
430
+ .flags = WDT_FLAG_RESET_SOC ,
431
+
432
+ /* Expire watchdog after max window */
433
+ .window .min = 0U ,
434
+ .window .max = 1000U ,
435
+ };
436
+
437
+ wdt_channel_id = wdt_install_timeout (wdt , & wdt_config );
438
+ if (wdt_channel_id < 0 ) {
439
+ printk ("Watchdog install error\n" );
440
+ return TC_FAIL ;
441
+ }
442
+
443
+ err = wdt_setup (wdt , (WDT_OPT_PAUSE_HALTED_BY_DBG | WDT_OPT_PAUSE_IN_SLEEP ));
444
+ if (err < 0 ) {
445
+ printk ("Watchdog setup error\n" );
446
+ ztest_test_skip ();
447
+ return TC_SKIP ;
448
+ }
449
+
450
+ for (int i = 0 ; i < 20 ; ++ i ) {
451
+ printk ("Feeding watchdog... %d\n" , i );
452
+ wdt_feed (wdt , 0 );
453
+ k_sleep (K_MSEC (2000 ));
454
+ }
455
+
456
+ TC_PRINT ("Waiting to restart MCU\n" );
457
+ m_testvalue = 0U ;
458
+ m_state = WDT_TEST_STATE_CHECK_RESET ;
459
+ while (1 ) {
460
+ k_yield ();
461
+ }
462
+
463
+ return TC_PASS ;
464
+ #endif
465
+ }
466
+
403
467
ZTEST (wdt_basic_test_suite , test_wdt )
404
468
{
405
- if ((m_testcase_index != 1U ) && (m_testcase_index != 2U )) {
469
+ if ((m_testcase_index != 1U ) && (m_testcase_index != 2U )
470
+ && (m_testcase_index != 3U )) {
406
471
zassert_true (test_wdt_no_callback () == TC_PASS );
407
472
}
408
473
if (m_testcase_index == 1U ) {
@@ -420,10 +485,14 @@ ZTEST(wdt_basic_test_suite, test_wdt)
420
485
#endif
421
486
}
422
487
if (m_testcase_index == 3U ) {
488
+ zassert_true (test_wdt_enable_wait_mode () == TC_PASS );
489
+ m_testcase_index ++ ;
490
+ }
491
+ if (m_testcase_index == 4U ) {
423
492
zassert_true (test_wdt_bad_window_max () == TC_PASS );
424
493
m_testcase_index ++ ;
425
494
}
426
- if (m_testcase_index > 3 ) {
495
+ if (m_testcase_index > 4 ) {
427
496
m_state = WDT_TEST_STATE_IDLE ;
428
497
}
429
498
}
0 commit comments