blob: 44691c252305f355d730d2eefeca965c327cfea2 [file] [log] [blame]
Andrew Geissler4cea4d22017-07-10 15:13:33 -05001#include <gtest/gtest.h>
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05302#include <occ_events.hpp>
Andrew Geissler4cea4d22017-07-10 15:13:33 -05003#include "powercap.hpp"
4
5using namespace open_power::occ;
6
7class VerifyOccInput : public ::testing::Test
8{
9 public:
10 VerifyOccInput() :
11 bus(sdbusplus::bus::new_default()),
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053012 rc(sd_event_default(&event)),
13 eventP(event),
14 occStatus(bus, eventP, "/test/path"),
Andrew Geissler4cea4d22017-07-10 15:13:33 -050015 pcap(bus,occStatus)
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053016 {
17 EXPECT_GE(rc, 0);
18 event = nullptr;
19 }
Andrew Geissler4cea4d22017-07-10 15:13:33 -050020 ~VerifyOccInput()
21 {}
22
23 sdbusplus::bus::bus bus;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053024 sd_event* event;
25 int rc;
26 open_power::occ::EventPtr eventP;
27
Andrew Geissler4cea4d22017-07-10 15:13:33 -050028 Status occStatus;
29 powercap::PowerCap pcap;
30};
31
32TEST_F(VerifyOccInput, PcapDisabled) {
33 uint32_t occInput = pcap.getOccInput(100,false);
34 EXPECT_EQ(occInput, 0);
35}
36
37TEST_F(VerifyOccInput, PcapEnabled) {
38 uint32_t occInput = pcap.getOccInput(100,true);
39 EXPECT_EQ(occInput, 90);
40}