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