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