test/watchdog: Use a unique_ptr for the watchdog
This lets us change out the watchdog with a watchdog constructed using
different parameters. Currently this functionality is not used, but it
is needed for a future change.
Change-Id: Ie1e7fbf2c7fc8bf2949237f2535177ecd46944a0
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/watchdog_test.hpp b/test/watchdog_test.hpp
index e332260..beeda66 100644
--- a/test/watchdog_test.hpp
+++ b/test/watchdog_test.hpp
@@ -1,5 +1,6 @@
#include <timer_test.hpp>
#include <chrono>
+#include <memory>
#include <watchdog.hpp>
using namespace std::chrono;
@@ -12,8 +13,9 @@
// Gets called as part of each TEST_F construction
WdogTest()
: bus(sdbusplus::bus::new_default()),
- wdog(bus, TEST_PATH, eventP),
- defaultInterval(milliseconds(wdog.interval())),
+ wdog(std::make_unique<phosphor::watchdog::Watchdog>(
+ bus, TEST_PATH, eventP)),
+ defaultInterval(milliseconds(wdog->interval())),
defaultDrift(30)
{
// Check for successful creation of
@@ -21,14 +23,14 @@
EXPECT_GE(rc, 0);
// Initially the watchdog would be disabled
- EXPECT_FALSE(wdog.enabled());
+ EXPECT_FALSE(wdog->enabled());
}
//sdbusplus handle
sdbusplus::bus::bus bus;
// Watchdog object
- phosphor::watchdog::Watchdog wdog;
+ std::unique_ptr<phosphor::watchdog::Watchdog> wdog;
// This is the default interval as given in Interface definition
milliseconds defaultInterval;