Andrew Geissler | 4cea4d2 | 2017-07-10 15:13:33 -0500 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 2 | #include <occ_events.hpp> |
Andrew Geissler | 4cea4d2 | 2017-07-10 15:13:33 -0500 | [diff] [blame] | 3 | #include "powercap.hpp" |
| 4 | |
| 5 | using namespace open_power::occ; |
| 6 | |
| 7 | class VerifyOccInput : public ::testing::Test |
| 8 | { |
| 9 | public: |
| 10 | VerifyOccInput() : |
| 11 | bus(sdbusplus::bus::new_default()), |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 12 | rc(sd_event_default(&event)), |
| 13 | eventP(event), |
| 14 | occStatus(bus, eventP, "/test/path"), |
Andrew Geissler | 4cea4d2 | 2017-07-10 15:13:33 -0500 | [diff] [blame] | 15 | pcap(bus,occStatus) |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 16 | { |
| 17 | EXPECT_GE(rc, 0); |
| 18 | event = nullptr; |
| 19 | } |
Andrew Geissler | 4cea4d2 | 2017-07-10 15:13:33 -0500 | [diff] [blame] | 20 | ~VerifyOccInput() |
| 21 | {} |
| 22 | |
| 23 | sdbusplus::bus::bus bus; |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 24 | sd_event* event; |
| 25 | int rc; |
| 26 | open_power::occ::EventPtr eventP; |
| 27 | |
Andrew Geissler | 4cea4d2 | 2017-07-10 15:13:33 -0500 | [diff] [blame] | 28 | Status occStatus; |
| 29 | powercap::PowerCap pcap; |
| 30 | }; |
| 31 | |
| 32 | TEST_F(VerifyOccInput, PcapDisabled) { |
| 33 | uint32_t occInput = pcap.getOccInput(100,false); |
| 34 | EXPECT_EQ(occInput, 0); |
| 35 | } |
| 36 | |
| 37 | TEST_F(VerifyOccInput, PcapEnabled) { |
| 38 | uint32_t occInput = pcap.getOccInput(100,true); |
| 39 | EXPECT_EQ(occInput, 90); |
| 40 | } |