Add unit tests for utils and refactor Makefiles

1. Add unit tests for utils;
2. Put the common code shared by app and utest into a library, and link the
library to app and utest.
This eliminates the duplicated compiled objects.
3. Update .gitignore

Change-Id: I05ee93c2b23748a1e038eeec3534d49b94911366
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index cd879f5..5311f9f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,22 +4,16 @@
 # Run all 'check' test programs
 TESTS = $(check_PROGRAMS)
 
-# Build/add utest to test suite
-utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS)
+utest_LDADD = $(top_builddir)/libocc_control.la -lstdc++fs
+
+utest_SOURCES = utest.cpp \
+                TestI2cOcc.cpp
+
+utest_CPPFLAGS = $(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) \
-                 $(PHOSPHOR_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 \
-              $(top_builddir)/occ_errors.o \
-              $(top_builddir)/i2c_occ.o \
-              $(top_builddir)/utils.o \
-              $(top_builddir)/org/open_power/OCC/Device/error.o
+
+utest_LDFLAGS = -lgmock_main \
+                $(PTHREAD_LIBS) \
+                $(OESDK_TESTCASE_FLAGS)