mirror of https://github.com/ARMmbed/mbed-os.git
Watchdog: Fix unittests
Compare get_timeout against the last timeout successfully set. Merge most of the test cases into one. Do not rely on the tests execution order. Fix the watchdog_api_stub to keep timeout value set by init function.pull/10857/head
parent
dc4d4a32f4
commit
968e270b0b
|
@ -35,34 +35,16 @@ protected:
|
|||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_start_pass)
|
||||
{
|
||||
EXPECT_TRUE(Watchdog::get_instance().start());
|
||||
}
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_start_fail)
|
||||
{
|
||||
EXPECT_FALSE(Watchdog::get_instance().start());
|
||||
}
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_stop_pass)
|
||||
TEST_F(TestWatchdog, test_watchdog_start_stop_get_timeout)
|
||||
{
|
||||
EXPECT_TRUE(Watchdog::get_instance().start(500));
|
||||
EXPECT_FALSE(Watchdog::get_instance().start(2000));
|
||||
EXPECT_TRUE(Watchdog::get_instance().stop());
|
||||
}
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_stop_fail)
|
||||
{
|
||||
EXPECT_FALSE(Watchdog::get_instance().stop());
|
||||
EXPECT_EQ(500, Watchdog::get_instance().get_timeout());
|
||||
}
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_get_max_timeout)
|
||||
{
|
||||
EXPECT_EQ(0xFFFFFFFF, Watchdog::get_instance().get_max_timeout());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TestWatchdog, test_watchdog_get_timeout)
|
||||
{
|
||||
EXPECT_EQ(Watchdog::watchdog_timeout, Watchdog::get_instance().get_timeout());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
|
||||
#if DEVICE_WATCHDOG
|
||||
|
||||
static uint32_t _timeout = 0;
|
||||
|
||||
watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
|
||||
{
|
||||
_timeout = config->timeout_ms;
|
||||
return WATCHDOG_STATUS_OK;
|
||||
}
|
||||
|
||||
|
@ -34,10 +37,9 @@ watchdog_status_t hal_watchdog_stop(void)
|
|||
|
||||
uint32_t hal_watchdog_get_reload_value(void)
|
||||
{
|
||||
return (500);
|
||||
return _timeout;
|
||||
}
|
||||
|
||||
|
||||
watchdog_features_t hal_watchdog_get_platform_features(void)
|
||||
{
|
||||
watchdog_features_t features;
|
||||
|
|
Loading…
Reference in New Issue