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/Makefile.am b/Makefile.am
index d71d6e5..0a2d05a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,19 +8,26 @@
 	occ_finder.hpp \
 	utils.hpp
 
+noinst_LTLIBRARIES = libocc_control.la
+
 sbin_PROGRAMS = openpower-occ-control
+
 openpower_occ_control_SOURCES = \
+	app.cpp
+
+libocc_control_la_SOURCES = \
 	occ_pass_through.cpp \
 	occ_status.cpp \
 	occ_device.cpp \
 	occ_errors.cpp \
-	app.cpp \
 	powercap.cpp \
 	org/open_power/OCC/Device/error.cpp \
 	occ_finder.cpp \
 	i2c_occ.cpp \
 	utils.cpp
 
+openpower_occ_control_LDADD = libocc_control.la -lstdc++fs
+
 BUILT_SOURCES =  org/open_power/OCC/Device/error.hpp \
                  org/open_power/OCC/Device/error.cpp \
                  occ_sensor.hpp
@@ -35,19 +42,27 @@
 occ_sensor.hpp: ${REQ_PY_SCRIPT} ${REQ_MAKO_FILE}
 	$(AM_V_GEN) ${PYTHON} ${REQ_PY_SCRIPT} -i ${YAML_PATH} > $@
 
-openpower_occ_control_LDFLAGS = \
+
+generic_ld_flags = \
 	$(SDBUSPLUS_LIBS) \
 	$(PHOSPHOR_LOGGING_LIBS) \
 	$(OPENPOWER_DBUS_INTERFACES_LIBS) \
-	$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
-        -lstdc++fs
+	$(PHOSPHOR_DBUS_INTERFACES_LIBS)
 
-openpower_occ_control_CXXFLAGS =
+generic_cxx_flags = \
 	$(SDBUSPLUS_CFLAGS) \
 	$(PHOSPHOR_LOGGING_CFLAGS) \
 	$(OPENPOWER_DBUS_INTERFACES_CFLAGS) \
 	$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
 
+libocc_control_la_CXXFLAGS = $(generic_cxx_flags)
+
+libocc_control_la_LDFLAGS = $(generic_ld_flags)
+
+openpower_occ_control_CXXFLAGS = $(generic_cxx_flags)
+
+openpower_occ_control_LDFLAGS = $(generic_ld_flags)
+
 org/open_power/OCC/Device/error.hpp: ${top_srcdir}/org/open_power/OCC/Device.errors.yaml
 	@mkdir -p `dirname $@`
 	$(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-header org.open_power.OCC.Device > $@