summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-03-01 11:07:36 -0800
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-07 11:22:55 +0000
commit8cd3839207e56116412cc621315bb664ccc70b7d (patch)
tree70582bf57576f2b5029ab5ba112456fd0742b9f2
parent25c1b20f973e2c3d71cf078b36b87769a248de6e (diff)
downloadphosphor-watchdog-8cd3839207e56116412cc621315bb664ccc70b7d.tar.gz
phosphor-watchdog-8cd3839207e56116412cc621315bb664ccc70b7d.zip
tests/watchdog: Cleanup our use of durations
We have lots of unnecessary constructors and forced duration casts. This change makes all of that logic simpler. Change-Id: Icfc6d51d75dfb67b3b4c252fbc32beeeded299ca Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--test/watchdog_test.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index 8a62cf2..90ec161 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -100,13 +100,12 @@ TEST_F(WdogTest, enableWdogAndWait5Seconds)
EXPECT_TRUE(wdog->enabled(true));
// Sleep for 5 seconds
- auto sleepTime = seconds(5s);
+ auto sleepTime = 5s;
std::this_thread::sleep_for(sleepTime);
// Get the remaining time again and expectation is that we get 25s
auto remaining = milliseconds(wdog->timeRemaining());
- auto expected = defaultInterval -
- duration_cast<milliseconds>(sleepTime);
+ auto expected = defaultInterval - sleepTime;
// Its possible that we are off by few msecs depending on
// how we get scheduled. So checking a range here.
@@ -129,9 +128,9 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
std::this_thread::sleep_for(1s);
// Next timer will expire in 5 seconds from now.
- auto expireTime = seconds(5s);
- auto newTime = duration_cast<milliseconds>(expireTime);
- wdog->timeRemaining(newTime.count());
+ auto expireTime = 5s;
+ auto expireTimeMs = milliseconds(expireTime).count();
+ EXPECT_EQ(expireTimeMs, wdog->timeRemaining(expireTimeMs));
// Waiting for expiration
EXPECT_EQ(expireTime - 1s, waitForWatchdog(expireTime));
@@ -146,12 +145,12 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
*/
TEST_F(WdogTest, verifyIntervalUpdateReceived)
{
- auto expireTime = seconds(5s);
- auto newTime = duration_cast<milliseconds>(expireTime);
- wdog->interval(newTime.count());
+ auto expireTime = 5s;
+ auto expireTimeMs = milliseconds(expireTime).count();
+ EXPECT_EQ(expireTimeMs, wdog->interval(expireTimeMs));
// Expect an update in the Interval
- EXPECT_EQ(newTime.count(), wdog->interval());
+ EXPECT_EQ(expireTimeMs, wdog->interval());
}
/** @brief Make sure that watchdog is started and enabled.
@@ -161,8 +160,7 @@ TEST_F(WdogTest, enableWdogAndWaitTillEnd)
{
// Enable and then verify
EXPECT_TRUE(wdog->enabled(true));
- auto expireTime = duration_cast<seconds>(
- milliseconds(defaultInterval));
+ auto expireTime = duration_cast<seconds>(defaultInterval);
// Waiting default expiration
EXPECT_EQ(expireTime - 1s, waitForWatchdog(expireTime));
OpenPOWER on IntegriCloud