summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangwan.kwon <sangwan.kwon@samsung.com>2017-09-24 21:35:23 -0400
committersangwan.kwon <sangwan.kwon@samsung.com>2019-02-18 15:50:28 +0900
commit45b997b210da396c14e660e299db38bf79af1e97 (patch)
tree0d4087ad40e0477c1a6a4646ba63607bdef379c9
parent392e8ffc59a36bdc4e2f61420e1a2c339b44d9ba (diff)
downloadcsr-framework-gcov.tar.gz
csr-framework-gcov.tar.bz2
csr-framework-gcov.zip
[GCOV] Enable to measure the test coveragegcov
Change-Id: I10668614519956b8950ce9bcf97cd52bbe27c077 Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
-rw-r--r--packaging/csr-framework.spec3
-rw-r--r--src/framework/common/connection.cpp3
-rw-r--r--src/framework/main/csr-main.cpp1
-rw-r--r--src/framework/ui/popup/main.cpp1
4 files changed, 8 insertions, 0 deletions
diff --git a/packaging/csr-framework.spec b/packaging/csr-framework.spec
index 334333e..a9ab328 100644
--- a/packaging/csr-framework.spec
+++ b/packaging/csr-framework.spec
@@ -136,6 +136,9 @@ Content Screening and Reputation framework (test program)
%define test_target target
%endif
+export CXXFLAGS="-fprofile-arcs -ftest-coverage"
+export LDFLAGS="-lgcov"
+
%cmake . \
-DCMAKE_BUILD_TYPE=%{?build_type:%build_type}%{!?build_type:RELEASE} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
diff --git a/src/framework/common/connection.cpp b/src/framework/common/connection.cpp
index 19f4e32..4f026a6 100644
--- a/src/framework/common/connection.cpp
+++ b/src/framework/common/connection.cpp
@@ -23,6 +23,8 @@
#include <utility>
+extern "C" void __gcov_flush();
+
namespace Csr {
Connection::Connection(Socket &&socket) noexcept :
@@ -50,6 +52,7 @@ Connection &Connection::operator=(Connection &&other) noexcept
void Connection::send(const RawBuffer &buf) const
{
+ __gcov_flush();
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 dd9d036..5ba590f 100644
--- a/src/framework/main/csr-main.cpp
+++ b/src/framework/main/csr-main.cpp
@@ -26,6 +26,7 @@
int main(void)
{
+ setenv("GCOV_PREFIX", "/opt/usr", 1);
try {
INFO("Start csr-server main!");
diff --git a/src/framework/ui/popup/main.cpp b/src/framework/ui/popup/main.cpp
index 23207cb..18b8b54 100644
--- a/src/framework/ui/popup/main.cpp
+++ b/src/framework/ui/popup/main.cpp
@@ -70,6 +70,7 @@ struct ElmRaii {
int main(int argc, char **argv)
{
+ setenv("GCOV_PREFIX", "/opt/usr", 1);
try {
Csr::Audit::Logger::setTag("CSR_POPUP");