blob: dc80cc20939bebba26adc7abd4c3484ba71234cc [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>
Edward A. James636577f2017-10-06 10:53:55 -05003#include <occ_manager.hpp>
Andrew Geissler4cea4d22017-07-10 15:13:33 -05004#include "powercap.hpp"
5
6using namespace open_power::occ;
7
8class VerifyOccInput : public ::testing::Test
9{
10 public:
11 VerifyOccInput() :
12 bus(sdbusplus::bus::new_default()),
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053013 rc(sd_event_default(&event)),
14 eventP(event),
Edward A. James636577f2017-10-06 10:53:55 -050015 manager(bus, eventP),
16 occStatus(bus, eventP, "/test/path/occ1", manager),
Andrew Geissler4cea4d22017-07-10 15:13:33 -050017 pcap(bus,occStatus)
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053018 {
19 EXPECT_GE(rc, 0);
20 event = nullptr;
21 }
Andrew Geissler4cea4d22017-07-10 15:13:33 -050022 ~VerifyOccInput()
23 {}
24
25 sdbusplus::bus::bus bus;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053026 sd_event* event;
27 int rc;
28 open_power::occ::EventPtr eventP;
29
Edward A. James636577f2017-10-06 10:53:55 -050030 Manager manager;
Andrew Geissler4cea4d22017-07-10 15:13:33 -050031 Status occStatus;
32 powercap::PowerCap pcap;
33};
34
35TEST_F(VerifyOccInput, PcapDisabled) {
36 uint32_t occInput = pcap.getOccInput(100,false);
37 EXPECT_EQ(occInput, 0);
38}
39
40TEST_F(VerifyOccInput, PcapEnabled) {
41 uint32_t occInput = pcap.getOccInput(100,true);
42 EXPECT_EQ(occInput, 90);
43}