1 #include <gtest/gtest.h> 2 #include <occ_events.hpp> 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()), 12 rc(sd_event_default(&event)), 13 eventP(event), 14 occStatus(bus, eventP, "/test/path/occ1"), 15 pcap(bus,occStatus) 16 { 17 EXPECT_GE(rc, 0); 18 event = nullptr; 19 } 20 ~VerifyOccInput() 21 {} 22 23 sdbusplus::bus::bus bus; 24 sd_event* event; 25 int rc; 26 open_power::occ::EventPtr eventP; 27 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 } 41