summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2017-08-17 12:32:22 -0700
committerPatrick Williams <patrick@stwcx.xyz>2017-09-12 16:38:06 +0000
commit96816341eb591865d011531b17d0be887f2e0e90 (patch)
tree631741a2ddca64656400eed3777816beda4e8102
parent09eebe3e62bfb58db890ec36d4447b9c80895c07 (diff)
downloadphosphor-watchdog-96816341eb591865d011531b17d0be887f2e0e90.tar.gz
phosphor-watchdog-96816341eb591865d011531b17d0be887f2e0e90.zip
Don't set Interval by setting TimeRemaining
This change allows one to set the TimeRemaining as a one-time shot, and also allows more straightforward control. -Changing the Interval doesn't reset the watchdog or update the TimeRemaining. -Changing the TimeRemaining doesn't set the Interval for future cycles. Change-Id: I03a3cdb9cc9e5c4bc034dc86d2b4324a5a4b7243 Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--test/watchdog_test.cpp15
-rw-r--r--watchdog.cpp3
2 files changed, 12 insertions, 6 deletions
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index f9a992c..d3e09e6 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -84,9 +84,6 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
auto newTime = duration_cast<milliseconds>(expireTime);
wdog.timeRemaining(newTime.count());
- // Expect an update in the Interval
- EXPECT_EQ(newTime.count(), wdog.interval());
-
// Waiting for expiration
int count = 0;
while(count < expireTime.count() && !wdog.timerExpired())
@@ -105,6 +102,18 @@ TEST_F(WdogTest, enableWdogAndResetTo5Seconds)
EXPECT_EQ(false, expired);
}
+/** @brief Make sure the Inteval can be updated directly.
+ */
+TEST_F(WdogTest, verifyIntervalUpdateReceived)
+{
+ auto expireTime = seconds(5s);
+ auto newTime = duration_cast<milliseconds>(expireTime);
+ wdog.interval(newTime.count());
+
+ // Expect an update in the Interval
+ EXPECT_EQ(newTime.count(), wdog.interval());
+}
+
/** @brief Make sure that watchdog is started and enabled.
* Wait default interval seconds and make sure that wdog has died
*/
diff --git a/watchdog.cpp b/watchdog.cpp
index 0c93d31..d0dc7f0 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -88,9 +88,6 @@ uint64_t Watchdog::timeRemaining(uint64_t value)
// Enable the timer.
timer.setEnabled<std::true_type>();
- // Update Interval in Base class.
- this->interval(value);
-
// Update Base class data.
return WatchdogInherits::timeRemaining(value);
}
OpenPOWER on IntegriCloud