diff options
author | William A. Kennington III <wak@google.com> | 2018-09-24 14:23:05 -0700 |
---|---|---|
committer | William A. Kennington III <wak@google.com> | 2018-09-24 14:28:17 -0700 |
commit | d4cbc5aad28f32c90e18d0fdd5ff8d1150fbd663 (patch) | |
tree | d39e48ffc2f281097c74baacb7c8b38482e2d2e3 | |
parent | c2c26cebc273398116bc011b26a261e179db18b7 (diff) | |
download | phosphor-watchdog-d4cbc5aad28f32c90e18d0fdd5ff8d1150fbd663.tar.gz phosphor-watchdog-d4cbc5aad28f32c90e18d0fdd5ff8d1150fbd663.zip |
test/watchdog: Test interval update
Adds a test to ensure that setting the interval on the watchdog affects
subsequent resetTimeRemaining() calls.
Tested:
Ran through a unit test run
Change-Id: Ibff14bbb40d5b93ffd5eaa5149f5cc9822e21d1e
Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r-- | test/watchdog_test.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp index 49890da..aa0ae0f 100644 --- a/test/watchdog_test.cpp +++ b/test/watchdog_test.cpp @@ -154,6 +154,33 @@ TEST_F(WdogTest, verifyIntervalUpdateReceived) EXPECT_EQ(expireTimeMs, wdog->interval()); } +/** @brief Make sure the Interval can be updated while the timer is running. + */ +TEST_F(WdogTest, verifyIntervalUpdateRunning) +{ + const auto oldInterval = milliseconds(wdog->interval()); + const auto newInterval = 5s; + + EXPECT_TRUE(wdog->enabled(true)); + auto remaining = milliseconds(wdog->timeRemaining()); + EXPECT_GE(oldInterval, remaining); + EXPECT_LE(oldInterval - defaultDrift, remaining); + EXPECT_EQ(newInterval, + milliseconds(wdog->interval(milliseconds(newInterval).count()))); + + // Expect only the interval to update + remaining = milliseconds(wdog->timeRemaining()); + EXPECT_GE(oldInterval, remaining); + EXPECT_LE(oldInterval - defaultDrift, remaining); + EXPECT_EQ(newInterval, milliseconds(wdog->interval())); + + // Expect reset to use the new interval + wdog->resetTimeRemaining(false); + remaining = milliseconds(wdog->timeRemaining()); + EXPECT_GE(newInterval, remaining); + EXPECT_LE(newInterval - defaultDrift, remaining); +} + /** @brief Make sure that watchdog is started and enabled. * Wait default interval seconds and make sure that wdog has died */ |