blob: eb9ca0ba58c971aa6feadd3b64c413f446822533 [file] [log] [blame]
Gunnar Mills94df8c92018-09-14 14:50:03 -05001#include "powercap.hpp"
2
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05303#include <occ_events.hpp>
Edward A. James636577f2017-10-06 10:53:55 -05004#include <occ_manager.hpp>
Gunnar Mills94df8c92018-09-14 14:50:03 -05005
6#include <gtest/gtest.h>
Andrew Geissler4cea4d22017-07-10 15:13:33 -05007
8using namespace open_power::occ;
9
10class VerifyOccInput : public ::testing::Test
11{
Gunnar Mills94df8c92018-09-14 14:50:03 -050012 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 Geissler4cea4d22017-07-10 15:13:33 -050024
Gunnar Mills94df8c92018-09-14 14:50:03 -050025 sdbusplus::bus::bus bus;
26 sd_event* event;
27 int rc;
28 open_power::occ::EventPtr eventP;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053029
Gunnar Mills94df8c92018-09-14 14:50:03 -050030 Manager manager;
31 Status occStatus;
32 powercap::PowerCap pcap;
Andrew Geissler4cea4d22017-07-10 15:13:33 -050033};
34
Gunnar Mills94df8c92018-09-14 14:50:03 -050035TEST_F(VerifyOccInput, PcapDisabled)
36{
37 uint32_t occInput = pcap.getOccInput(100, false);
Andrew Geissler4cea4d22017-07-10 15:13:33 -050038 EXPECT_EQ(occInput, 0);
39}
40
Gunnar Mills94df8c92018-09-14 14:50:03 -050041TEST_F(VerifyOccInput, PcapEnabled)
42{
43 uint32_t occInput = pcap.getOccInput(100, true);
Andrew Geissler4cea4d22017-07-10 15:13:33 -050044 EXPECT_EQ(occInput, 90);
45}