spec file :add gcov option for checking code coverage 86/264486/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211028.121544 accepted/tizen/unified/20210923.133037 submit/tizen/20210923.064949 submit/tizen_6.5/20211028.163101 tizen_6.5.m2_release
authorDuna Oh <duna.oh@samsung.com>
Fri, 17 Sep 2021 07:43:04 +0000 (16:43 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 23 Sep 2021 06:24:26 +0000 (15:24 +0900)
Change-Id: I1ecd86ea9b6c0eae1a99a85e603160375f532089

packaging/mmifw.spec
tests/mmifw-tests.cpp
tests/mmifw-tests.h

index 3726306..c65c9cb 100644 (file)
@@ -1,3 +1,5 @@
+%define USE_GCOV 0
+
 Name:          mmifw
 Version:       0.0.1
 Release:       0
@@ -46,6 +48,11 @@ cp %{SOURCE1004} .
 #cp -af mmifw_proxy.* ./src/interface/
 
 %build
+%if "%{USE_GCOV}" == "1"
+CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+LDFLAGS+=" -lgcov"
+%endif
 meson setup --prefix=/usr \
        --bindir %{_bindir} \
        --libdir %{_libdir} \
index 29a65f8..c9659e1 100644 (file)
@@ -27,6 +27,9 @@ int main(int argc, char **argv)
 {
        auto testResults = false;
 
+#ifdef TIZEN_TEST_GCOV
+       setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
        try
        {
                ::testing::InitGoogleMock(&argc, argv);
@@ -48,6 +51,9 @@ int main(int argc, char **argv)
                PRINT("GoogleTestFailureException has been thrown: %s\n", e.what());
        }
 
+#ifdef TIZEN_TEST_GCOV
+       __gcov_flush();
+#endif
        return testResults;
 }
 
index 29341ab..121c9da 100644 (file)
@@ -32,6 +32,9 @@
 
 #define MAX_WAIT_TIME 300000
 
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
 extern void wait_for_connect();
 
 using ::testing::TestWithParam;