Lei YU | 9623282 | 2017-01-20 14:05:46 +0800 | [diff] [blame^] | 1 | #include <sdbusplus/bus.hpp> |
| 2 | #include <gtest/gtest.h> |
| 3 | |
| 4 | #include "bmc_epoch.hpp" |
| 5 | #include "config.h" |
| 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace time |
| 10 | { |
| 11 | |
| 12 | class TestBmcEpoch : public testing::Test |
| 13 | { |
| 14 | public: |
| 15 | using Mode = EpochBase::Mode; |
| 16 | using Owner = EpochBase::Owner; |
| 17 | |
| 18 | sdbusplus::bus::bus bus; |
| 19 | BmcEpoch bmcEpoch; |
| 20 | |
| 21 | TestBmcEpoch() |
| 22 | : bus(sdbusplus::bus::new_default()), |
| 23 | bmcEpoch(bus, OBJPATH_BMC) |
| 24 | { |
| 25 | // Empty |
| 26 | } |
| 27 | |
| 28 | // Proxies for BmcEpoch's private members and functions |
| 29 | Mode getTimeMode() |
| 30 | { |
| 31 | return bmcEpoch.timeMode; |
| 32 | } |
| 33 | Owner getTimeOwner() |
| 34 | { |
| 35 | return bmcEpoch.timeOwner; |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | TEST_F(TestBmcEpoch, empty) |
| 40 | { |
| 41 | EXPECT_EQ(Mode::NTP, getTimeMode()); |
| 42 | EXPECT_EQ(Owner::BMC, getTimeOwner()); |
| 43 | } |
| 44 | |
| 45 | TEST_F(TestBmcEpoch, getElapsed) |
| 46 | { |
| 47 | auto t1 = bmcEpoch.elapsed(); |
| 48 | EXPECT_NE(0, t1); |
| 49 | auto t2 = bmcEpoch.elapsed(); |
| 50 | EXPECT_GE(t2, t1); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | } |
| 55 | } |