Wrapping auto-ran unit tests with valgrind.
authorErich Keane <erich.keane@intel.com>
Wed, 1 Apr 2015 20:38:17 +0000 (13:38 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 2 Apr 2015 18:27:22 +0000 (18:27 +0000)
Along with Jenkins' valgrind publisher plugin, the build server will now
be keeping track of memory leaks that are/can be tracked by the unit
tests.

Change-Id: Ic5f20ef07faa57e4689fa334b628fcd3e44b0f1e
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/621
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
resource/csdk/connectivity/test/SConscript
resource/csdk/stack/test/SConscript
resource/unittests/OCRepresentationTest.cpp
resource/unittests/SConscript

index d19b5c4..7e08d8e 100644 (file)
@@ -81,5 +81,5 @@ if env.get('TEST') == '1':
                 catest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
                 catest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
                 catest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
-                ut = catest_env.Command ('ut', None, out_dir + '/resource/csdk/connectivity/test/catests')
+                ut = catest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_connectivity_test.memcheck ' + out_dir + 'resource/csdk/connectivity/test/catests')
                 AlwaysBuild ('ut')
index fe38e51..300eed7 100644 (file)
@@ -75,5 +75,5 @@ if env.get('TEST') == '1':
                stacktest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
                stacktest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
                stacktest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
-               ut = stacktest_env.Command ('ut', None, out_dir + '/resource/csdk/stack/test/stacktests')
+               ut = stacktest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_stack_test.memcheck ' + out_dir + 'resource/csdk/stack/test/stacktests')
                AlwaysBuild ('ut')
index 04a2297..befcdcb 100644 (file)
@@ -29,11 +29,11 @@ namespace OCRepresentationTest
     using std::string;
     using std::vector;
 
-    template<typename T>
-    void parsedEqual(T expected, const std::string& actualStr)
+    void parsedEqual(double expected, const std::string& actualStr)
     {
-        T actual = boost::lexical_cast<T>(actualStr);
-        EXPECT_LT(std::abs(expected - actual), std::numeric_limits<T>::epsilon());
+        double actual = boost::lexical_cast<double>(actualStr);
+        EXPECT_GE(actual, expected - .0000001);
+        EXPECT_LE(actual, expected + .0000001);
     }
 
     // getValueToString(all types)
index 63a2ada..4f50aa1 100644 (file)
@@ -84,5 +84,5 @@ if env.get('TEST') == '1':
                unittests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
                unittests_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
                ut = unittests_env.Command ('ut', None,
-                [out_dir + '/resource/unittests/unittests'])
+                [ 'valgrind --leak-check=full --xml=yes --xml-file=resource_unittests_unittests.memcheck ' + out_dir + 'resource/unittests/unittests'])
                AlwaysBuild ('ut')