add gcov option for checking code coverage 47/241847/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 19 Aug 2020 04:18:51 +0000 (13:18 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:12:05 +0000 (19:12 +0900)
Change-Id: Id3eebafe701c46bb08ec11949c00a79ee0330640
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
packaging/libds.spec
tests/libds-tests.cpp
tests/libds-tests.h

index 488d26c..81ef44d 100644 (file)
@@ -1,3 +1,5 @@
+%define USE_GCOV 0
+
 Name:           libds
 Version:        0.0.1
 Release:        0
@@ -65,6 +67,10 @@ Test module for testing libtbm APIs
 cp %{SOURCE1001} .
 
 %build
+%if "%{USE_GCOV}" == "1"
+CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+LDFLAGS+=" -lgcov"
+%endif
 meson setup \
     --prefix /usr \
     --libdir %{_libdir} \
index 6ac27a3..4a9ed5a 100644 (file)
@@ -29,6 +29,10 @@ int main(int argc, char **argv)
 {
        auto AllTestSuccess = false;
 
+#ifdef TIZEN_TEST_GCOV
+       setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
        try {
                ::testing::InitGoogleMock(&argc, argv);
                ::testing::FLAGS_gtest_death_test_style = "fast";
@@ -45,5 +49,8 @@ int main(int argc, char **argv)
                std::cout << "\n";
        }
 
+#ifdef TIZEN_TEST_GCOV
+       __gcov_flush();
+#endif
        return AllTestSuccess;
 }
index dfb2119..312a732 100644 (file)
 
 #include "libds-mock.h"
 
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
 using ::testing::TestWithParam;
 using ::testing::Bool;
 using ::testing::Values;