blob: 3f6ffea6fa81bcd52a3a2e3f47213445dc280f30 [file] [log] [blame]
Vishwanatha Subbanna00bd3772017-05-31 14:53:42 +05301#include <iostream>
2#include <gtest/gtest.h>
3#include <timer.hpp>
4
5// Base class for testing Timer
6class TimerTest : public testing::Test
7{
8 public:
9 // systemd event handler
10 sd_event* events;
11
12 // Need this so that events can be initialized.
13 int rc;
14
15 // Tells if the watchdog timer expired.
16 bool expired = false;
17
18 // Gets called as part of each TEST_F construction
19 TimerTest()
20 : rc(sd_event_default(&events)),
21 eventP(events)
22 {
23 // Check for successful creation of
24 // event handler and bus handler
25 EXPECT_GE(rc, 0);
26
27 // Its already wrapped in eventP
28 events = nullptr;
29 }
30
31 // unique_ptr for sd_event
32 phosphor::watchdog::EventPtr eventP;
33
34 // Handler called by timer expiration
35 inline void timeOutHandler()
36 {
37 std::cout << "Time out handler called" << std::endl;
38 expired = true;
39 }
40};