1 #include "powercap.hpp" 2 3 #include <occ_events.hpp> 4 #include <occ_manager.hpp> 5 6 #include <gtest/gtest.h> 7 8 using namespace open_power::occ; 9 10 class VerifyOccInput : public ::testing::Test 11 { 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 } 24 25 sdbusplus::bus::bus bus; 26 sd_event* event; 27 int rc; 28 open_power::occ::EventPtr eventP; 29 30 Manager manager; 31 Status occStatus; 32 powercap::PowerCap pcap; 33 }; 34 35 TEST_F(VerifyOccInput, PcapDisabled) 36 { 37 uint32_t occInput = pcap.getOccInput(100, false); 38 EXPECT_EQ(occInput, 0); 39 } 40 41 TEST_F(VerifyOccInput, PcapEnabled) 42 { 43 uint32_t occInput = pcap.getOccInput(100, true); 44 EXPECT_EQ(occInput, 90); 45 } 46