summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangwan Kwon <sangwan.kwon@samsung.com>2019-07-05 08:36:50 +0900
committerSangwan Kwon <sangwan.kwon@samsung.com>2019-07-08 08:18:00 +0900
commite929975b130a4181ca4669727088844255e884a5 (patch)
tree8a6e1028981f01a96a52a077a7d38c41e1197b06
parent24284fe45d4c23407cfd3df0c3aa2ac102434df0 (diff)
downloadcsr-framework-e929975b130a4181ca4669727088844255e884a5.tar.gz
csr-framework-e929975b130a4181ca4669727088844255e884a5.tar.bz2
csr-framework-e929975b130a4181ca4669727088844255e884a5.zip
Change-Id: I383849a301f33017d332dabb4650e0763d71419b Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
-rw-r--r--CMakeLists.txt4
-rw-r--r--packaging/csr-framework.spec44
-rw-r--r--src/framework/common/connection.cpp4
-rw-r--r--src/framework/main/csr-main.cpp4
-rw-r--r--src/framework/ui/popup/main.cpp4
-rw-r--r--test/internals/test-main.cpp3
-rw-r--r--test/popup/test-main.cpp3
-rw-r--r--test/test-main.cpp3
-rw-r--r--test/thread-pool/test-main.cpp3
9 files changed, 67 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d4503e..ea9a599 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,10 @@ IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+IF (BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ENDIF (BUILD_GCOV)
+
SET(TARGET_CSR_SERVER ${SERVICE_NAME}-server)
SET(TARGET_CSR_CLIENT ${SERVICE_NAME}-client)
SET(TARGET_CSR_COMMON ${SERVICE_NAME}-common)
diff --git a/packaging/csr-framework.spec b/packaging/csr-framework.spec
index 26ec5e4..3b69b24 100644
--- a/packaging/csr-framework.spec
+++ b/packaging/csr-framework.spec
@@ -119,11 +119,22 @@ BuildRequires: boost-devel
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(storage)
+Requires: boost-test
Requires: %{name} = %{version}
%description test
Content Screening and Reputation framework (test program)
+%if 0%{?gcov:1}
+%package gcov
+Summary: CSR framework (gcov)
+Group: Security/Testing
+BuildRequires: lcov
+
+%description gcov
+Content Screening and Reputation framework (gcov)
+%endif
+
%prep
%setup -q
@@ -136,8 +147,12 @@ Content Screening and Reputation framework (test program)
%define test_target target
%endif
-export CXXFLAGS="-fprofile-arcs -ftest-coverage"
-export LDFLAGS="-lgcov"
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
%cmake . \
-DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
@@ -174,10 +189,16 @@ export LDFLAGS="-lgcov"
%endif
-DTZ_SYS_STORAGE=%TZ_SYS_STORAGE \
-DTZ_SYS_RW_APP=%TZ_SYS_RW_APP \
- -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP
+ -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
make %{?jobs:-j%jobs}
+%if 0%{?gcov:1}
+mkdir -p gcov-obj
+find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+%endif
+
%install
%make_install
%install_service sockets.target.wants %{service_name}-cs.socket
@@ -195,6 +216,11 @@ mkdir -p %{buildroot}%{engine_rw_working_dir}
%find_lang %{service_name}
+%if 0%{?gcov:1}
+mkdir -p %{buildroot}%{_datadir}/gcov/obj
+install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+%endif
+
%post
set_cap_script=%{ro_data_dir}/security-config/set_capability
if [ -f $set_cap_script ]; then
@@ -255,6 +281,13 @@ touch %{engine_rw_working_dir}/csret_cs_virus_signatures
touch %{engine_rw_working_dir}/csret_wp_risky_urls
%endif
+%if 0%{?gcov:1}
+chmod 777 -R /tmp/home/abuild/rpmbuild/BUILD/csr-framework-*
+su - owner -c %{bin_dir}/%{service_name}-test
+%{bin_dir}/%{service_name}-internal-test
+%{bin_dir}/%{service_name}-threadpool-test
+%endif
+
%files -f %{service_name}.lang
%defattr(-,root,root,-)
%manifest %{service_name}.manifest
@@ -345,3 +378,8 @@ touch %{engine_rw_working_dir}/csret_wp_risky_urls
%{engine_dir}/lib%{service_name}-wp-engine.so
%attr(-, %{service_user}, %{service_group}) %{engine_rw_working_dir}/*
%endif
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+%endif
diff --git a/src/framework/common/connection.cpp b/src/framework/common/connection.cpp
index 4f026a6..421dde7 100644
--- a/src/framework/common/connection.cpp
+++ b/src/framework/common/connection.cpp
@@ -23,7 +23,9 @@
#include <utility>
+#ifdef TIZEN_TEST_GCOV
extern "C" void __gcov_flush();
+#endif
namespace Csr {
@@ -52,7 +54,9 @@ Connection &Connection::operator=(Connection &&other) noexcept
void Connection::send(const RawBuffer &buf) const
{
+#ifdef TIZEN_TEST_GCOV
__gcov_flush();
+#endif
std::lock_guard<std::mutex> lock(this->m_mSend);
this->m_socket.write(buf);
}
diff --git a/src/framework/main/csr-main.cpp b/src/framework/main/csr-main.cpp
index 5ba590f..ed6971a 100644
--- a/src/framework/main/csr-main.cpp
+++ b/src/framework/main/csr-main.cpp
@@ -26,7 +26,9 @@
int main(void)
{
- setenv("GCOV_PREFIX", "/opt/usr", 1);
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
try {
INFO("Start csr-server main!");
diff --git a/src/framework/ui/popup/main.cpp b/src/framework/ui/popup/main.cpp
index 18b8b54..b00c4c6 100644
--- a/src/framework/ui/popup/main.cpp
+++ b/src/framework/ui/popup/main.cpp
@@ -70,7 +70,9 @@ struct ElmRaii {
int main(int argc, char **argv)
{
- setenv("GCOV_PREFIX", "/opt/usr", 1);
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
try {
Csr::Audit::Logger::setTag("CSR_POPUP");
diff --git a/test/internals/test-main.cpp b/test/internals/test-main.cpp
index 84333d2..029887a 100644
--- a/test/internals/test-main.cpp
+++ b/test/internals/test-main.cpp
@@ -33,6 +33,9 @@
struct TestConfig {
TestConfig()
{
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
boost::unit_test::unit_test_log.set_threshold_level(
boost::unit_test::log_test_units);
boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
diff --git a/test/popup/test-main.cpp b/test/popup/test-main.cpp
index ad3c19e..feed79b 100644
--- a/test/popup/test-main.cpp
+++ b/test/popup/test-main.cpp
@@ -28,6 +28,9 @@
struct TestConfig {
TestConfig()
{
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
boost::unit_test::unit_test_log.set_threshold_level(
boost::unit_test::log_test_units);
boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
diff --git a/test/test-main.cpp b/test/test-main.cpp
index f661504..9131ac9 100644
--- a/test/test-main.cpp
+++ b/test/test-main.cpp
@@ -78,6 +78,9 @@ csr_state_e setEngineState(csr_engine_id_e id, csr_state_e state)
struct TestConfig {
TestConfig()
{
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
boost::unit_test::unit_test_log.set_threshold_level(
boost::unit_test::log_test_units);
boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
diff --git a/test/thread-pool/test-main.cpp b/test/thread-pool/test-main.cpp
index 35c4440..74c5ee5 100644
--- a/test/thread-pool/test-main.cpp
+++ b/test/thread-pool/test-main.cpp
@@ -28,6 +28,9 @@
struct TestConfig {
TestConfig()
{
+#ifdef TIZEN_TEST_GCOV
+ ::setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
boost::unit_test::unit_test_log.set_threshold_level(
boost::unit_test::log_test_units);
boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);