Determine pcap value to send to occ
Change-Id: Ie60aac151f5fd8ce091020ce756834e4877cbc93
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..6022c65
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,20 @@
+AM_CPPFLAGS = -I$(top_srcdir)
+check_PROGRAMS = utest
+
+# Run all 'check' test programs
+TESTS = $(check_PROGRAMS)
+
+# Build/add utest to test suite
+utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS)
+utest_CXXFLAGS = $(PTHREAD_CFLAGS)
+utest_LDFLAGS = -lgtest_main -lgtest \
+ $(PTHREAD_LIBS) \
+ $(OESDK_TESTCASE_FLAGS) \
+ $(SYSTEMD_LIBS) \
+ ${SDBUSPLUS_LIBS} \
+ $(OPENPOWER_DBUS_INTERFACES_LIBS) \
+ -lstdc++fs
+utest_SOURCES = utest.cpp
+utest_LDADD = $(top_builddir)/powercap.o \
+ $(top_builddir)/occ_status.o \
+ $(top_builddir)/occ_device.o
diff --git a/test/utest.cpp b/test/utest.cpp
new file mode 100644
index 0000000..e99d996
--- /dev/null
+++ b/test/utest.cpp
@@ -0,0 +1,30 @@
+#include <gtest/gtest.h>
+#include "powercap.hpp"
+
+using namespace open_power::occ;
+
+class VerifyOccInput : public ::testing::Test
+{
+ public:
+ VerifyOccInput() :
+ bus(sdbusplus::bus::new_default()),
+ occStatus(bus,"/test/path"),
+ pcap(bus,occStatus)
+ {}
+ ~VerifyOccInput()
+ {}
+
+ sdbusplus::bus::bus bus;
+ Status occStatus;
+ powercap::PowerCap pcap;
+};
+
+TEST_F(VerifyOccInput, PcapDisabled) {
+ uint32_t occInput = pcap.getOccInput(100,false);
+ EXPECT_EQ(occInput, 0);
+}
+
+TEST_F(VerifyOccInput, PcapEnabled) {
+ uint32_t occInput = pcap.getOccInput(100,true);
+ EXPECT_EQ(occInput, 90);
+}