summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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");