Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 1 | #include <timer_test.hpp> |
| 2 | #include <chrono> |
William A. Kennington III | f0fe2d6 | 2018-02-28 15:20:16 -0800 | [diff] [blame] | 3 | #include <memory> |
Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 4 | #include <watchdog.hpp> |
| 5 | |
| 6 | using namespace std::chrono; |
| 7 | using namespace std::chrono_literals; |
| 8 | |
| 9 | // Test Watchdog functionality |
| 10 | class WdogTest : public TimerTest |
| 11 | { |
| 12 | public: |
| 13 | // Gets called as part of each TEST_F construction |
| 14 | WdogTest() |
| 15 | : bus(sdbusplus::bus::new_default()), |
William A. Kennington III | f0fe2d6 | 2018-02-28 15:20:16 -0800 | [diff] [blame] | 16 | wdog(std::make_unique<phosphor::watchdog::Watchdog>( |
| 17 | bus, TEST_PATH, eventP)), |
| 18 | defaultInterval(milliseconds(wdog->interval())), |
Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 19 | defaultDrift(30) |
| 20 | { |
| 21 | // Check for successful creation of |
| 22 | // event handler and bus handler |
| 23 | EXPECT_GE(rc, 0); |
| 24 | |
| 25 | // Initially the watchdog would be disabled |
William A. Kennington III | f0fe2d6 | 2018-02-28 15:20:16 -0800 | [diff] [blame] | 26 | EXPECT_FALSE(wdog->enabled()); |
Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | //sdbusplus handle |
| 30 | sdbusplus::bus::bus bus; |
| 31 | |
| 32 | // Watchdog object |
William A. Kennington III | f0fe2d6 | 2018-02-28 15:20:16 -0800 | [diff] [blame] | 33 | std::unique_ptr<phosphor::watchdog::Watchdog> wdog; |
Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 34 | |
| 35 | // This is the default interval as given in Interface definition |
| 36 | milliseconds defaultInterval; |
| 37 | |
| 38 | // Acceptable drift when we compare the interval to timeRemaining. |
| 39 | // This is needed since it depends on when do we get scheduled and it |
| 40 | // has happened that remaining time was off by few msecs. |
| 41 | milliseconds defaultDrift; |
| 42 | |
William A. Kennington III | ab17520 | 2018-02-28 15:26:06 -0800 | [diff] [blame] | 43 | protected: |
Vishwanatha Subbanna | 00bd377 | 2017-05-31 14:53:42 +0530 | [diff] [blame] | 44 | // Dummy name for object path |
| 45 | // This is just to satisfy the constructor. Does not have |
| 46 | // a need to check if the objects paths have been created. |
| 47 | static constexpr auto TEST_PATH = "/test/path"; |
| 48 | }; |