summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-04-17 17:51:56 -0700
committerPatrick Venture <venture@google.com>2018-04-24 19:58:18 +0000
commit609fe98205fe8f4bd0dc6b9fca66877e2edf186d (patch)
treebd16de833ea75277aca274c86a620c3c3d3df2ce
parentc635e8609f5246224dfba7db57991de0b1c5327f (diff)
downloadphosphor-hwmon-609fe98205fe8f4bd0dc6b9fca66877e2edf186d.tar.gz
phosphor-hwmon-609fe98205fe8f4bd0dc6b9fca66877e2edf186d.zip
hwmon module unit-tests -- first one
This patchset just starts the process of adding unit-tests to the hwmon module. Change-Id: I569aa97658b0ff56634ddf1a599fedb4caa95abe Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac2
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am20
-rw-r--r--test/hwmon_unittest.cpp12
5 files changed, 35 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 27db186..d2b7989 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,4 +27,4 @@ libhwmon_la_SOURCES = \
timer.cpp \
hwmon.cpp
-SUBDIRS = . msl tools
+SUBDIRS = . msl test tools
diff --git a/configure.ac b/configure.ac
index 1e0f27d..086dee0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,5 +90,5 @@ AC_DEFINE_UNQUOTED([BUSNAME_PREFIX], ["$BUSNAME_PREFIX"], [The DBus busname pref
AC_DEFINE_UNQUOTED([SENSOR_ROOT], ["$SENSOR_ROOT"], [The DBus sensors namespace root.])
# Create configured output
-AC_CONFIG_FILES([Makefile tools/Makefile msl/Makefile])
+AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile msl/Makefile])
AC_OUTPUT
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..70cb196
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+test-suite.log
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..7f302ca
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,20 @@
+AM_CPPFLAGS = -I$(top_srcdir)/ $(GTEST_CFLAGS) $(GMOCK_CFLAGS)
+AM_CXXFLAGS = $(PTHREAD_CFLAGS) \
+ $(GTEST_CFLAGS) \
+ $(GMOCK_CFLAGS) \
+ $(SDBUSPLUS_CFLAGS) \
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
+AM_LDFLAGS = $(GTEST_LIBS) \
+ $(PTHREAD_LIBS) \
+ $(GMOCK_LIBS) \
+ $(OESDK_TESTCASE_FLAGS) \
+ $(SDBUSPLUS_LIBS) \
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS)
+
+# Run all 'check' test programs
+check_PROGRAMS = hwmon_unittest
+TESTS = $(check_PROGRAMS)
+
+hwmon_unittest_SOURCES = hwmon_unittest.cpp
+hwmon_unittest_LDADD = $(top_builddir)/hwmon.o
+
diff --git a/test/hwmon_unittest.cpp b/test/hwmon_unittest.cpp
new file mode 100644
index 0000000..035d098
--- /dev/null
+++ b/test/hwmon_unittest.cpp
@@ -0,0 +1,12 @@
+#include "hwmon.hpp"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+TEST(HwmonTest, InvalidType) {
+
+ hwmon::Attributes attrs;
+ EXPECT_FALSE(hwmon::getAttributes("invalid", attrs));
+
+}
+
OpenPOWER on IntegriCloud