summaryrefslogtreecommitdiffstats
path: root/test/watchdog_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/watchdog_test.cpp')
-rw-r--r--test/watchdog_test.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index a76a914..f846532 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -5,27 +5,27 @@ using namespace phosphor::watchdog;
/** @brief Make sure that watchdog is started and not enabled */
TEST_F(WdogTest, createWdogAndDontEnable)
{
- EXPECT_FALSE(wdog.enabled());
- EXPECT_EQ(0, wdog.timeRemaining());
- EXPECT_FALSE(wdog.timerExpired());
+ EXPECT_FALSE(wdog->enabled());
+ EXPECT_EQ(0, wdog->timeRemaining());
+ EXPECT_FALSE(wdog->timerExpired());
}
/** @brief Make sure that watchdog is started and enabled */
TEST_F(WdogTest, createWdogAndEnable)
{
// Enable and then verify
- EXPECT_TRUE(wdog.enabled(true));
- EXPECT_FALSE(wdog.timerExpired());
+ EXPECT_TRUE(wdog->enabled(true));
+ EXPECT_FALSE(wdog->timerExpired());
// Get the configured interval
- auto remaining = milliseconds(wdog.timeRemaining());
+ auto remaining = milliseconds(wdog->timeRemaining());
// Its possible that we are off by few msecs depending on
// how we get scheduled. So checking a range here.
EXPECT_TRUE((remaining >= defaultInterval - defaultDrift) &&
(remaining <= defaultInterval));
- EXPECT_FALSE(wdog.timerExpired());
+ EXPECT_FALSE(wdog->timerExpired());
}
/** @brief Make sure that watchdog is started and enabled.
@@ -34,12 +34,12 @@ TEST_F(WdogTest, createWdogAndEnable)
TEST_F(WdogTest, createWdogAndEnableThenDisable)
{
// Enable and then verify
- EXPECT_TRUE(wdog.enabled(true));
+ EXPECT_TRUE(wdog->enabled(true));
// Disable and then verify
- EXPECT_FALSE(wdog.enabled(false));
- EXPECT_FALSE(wdog.enabled());
- EXPECT_EQ(0, wdog.timeRemaining());
+ EXPECT_FALSE(wdog->enabled(false));
+ EXPECT_FALSE(wdog->enabled());
+ EXPECT_EQ(0, wdog->timeRemaining());
}
/** @brief Make sure that watchdog is started and enabled.
@@ -49,14 +49,14 @@ TEST_F(WdogTest, createWdogAndEnableThenDisable)
TEST_F(WdogTest, enableWdogAndWait5Seconds)
{
// Enable and then verify
- EXPECT_TRUE(wdog.enabled(true));
+ EXPECT_TRUE(wdog->enabled(true));
// Sleep for 5 seconds
auto sleepTime = seconds(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 remaining = milliseconds(wdog->timeRemaining());
auto expected = defaultInterval -
duration_cast<milliseconds>(sleepTime);
@@ -64,7 +64,7 @@ TEST_F(WdogTest, enableWdogAndWait5Seconds)
// how we get scheduled. So checking a range here.
EXPECT_TRUE((remaining >= expected - defaultDrift) &&
(remaining <= expected));
- EXPECT_FALSE(wdog.timerExpired());
+ EXPECT_FALSE(wdog->timerExpired());
}
/** @brief Make sure that watchdog is started and enabled.
@@ -74,7 +74,7 @@ TEST_F(WdogTest, enableWdogAndWait5Seconds)
TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
{
// Enable and then verify
- EXPECT_TRUE(wdog.enabled(true));
+ EXPECT_TRUE(wdog->enabled(true));
// Sleep for 1 second
std::this_thread::sleep_for(1s);
@@ -82,11 +82,11 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
// Next timer will expire in 5 seconds from now.
auto expireTime = seconds(5s);
auto newTime = duration_cast<milliseconds>(expireTime);
- wdog.timeRemaining(newTime.count());
+ wdog->timeRemaining(newTime.count());
// Waiting for expiration
int count = 0;
- while(count < expireTime.count() && !wdog.timerExpired())
+ while(count < expireTime.count() && !wdog->timerExpired())
{
// Returns -0- on timeout and positive number on dispatch
auto sleepTime = duration_cast<microseconds>(seconds(1s));
@@ -95,7 +95,7 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
count++;
}
}
- EXPECT_TRUE(wdog.timerExpired());
+ EXPECT_TRUE(wdog->timerExpired());
EXPECT_EQ(expireTime.count() - 1 , count);
// Make sure secondary callback was not called.
@@ -108,10 +108,10 @@ TEST_F(WdogTest, verifyIntervalUpdateReceived)
{
auto expireTime = seconds(5s);
auto newTime = duration_cast<milliseconds>(expireTime);
- wdog.interval(newTime.count());
+ wdog->interval(newTime.count());
// Expect an update in the Interval
- EXPECT_EQ(newTime.count(), wdog.interval());
+ EXPECT_EQ(newTime.count(), wdog->interval());
}
/** @brief Make sure that watchdog is started and enabled.
@@ -120,13 +120,13 @@ TEST_F(WdogTest, verifyIntervalUpdateReceived)
TEST_F(WdogTest, enableWdogAndWaitTillEnd)
{
// Enable and then verify
- EXPECT_TRUE(wdog.enabled(true));
+ EXPECT_TRUE(wdog->enabled(true));
auto expireTime = duration_cast<seconds>(
milliseconds(defaultInterval));
// Waiting default expiration
int count = 0;
- while(count < expireTime.count() && !wdog.timerExpired())
+ while(count < expireTime.count() && !wdog->timerExpired())
{
// Returns -0- on timeout and positive number on dispatch
auto sleepTime = duration_cast<microseconds>(seconds(1s));
@@ -135,8 +135,8 @@ TEST_F(WdogTest, enableWdogAndWaitTillEnd)
count++;
}
}
- EXPECT_TRUE(wdog.enabled());
- EXPECT_EQ(0, wdog.timeRemaining());
- EXPECT_TRUE(wdog.timerExpired());
+ EXPECT_TRUE(wdog->enabled());
+ EXPECT_EQ(0, wdog->timeRemaining());
+ EXPECT_TRUE(wdog->timerExpired());
EXPECT_EQ(expireTime.count() - 1, count);
}
OpenPOWER on IntegriCloud