ci: enable code coverage
Change-Id: I1fb68bc05b1a4a75c249a11c87fd6139c1700e75
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100755
index 0000000..6048b1c
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -ex
+
+if [[ $JOB_NAME == *"code-coverage" ]]; then
+ lcov --quiet \
+ --capture \
+ --directory . \
+ --no-external \
+ --rc lcov_branch_coverage=1 \
+ --output-file build/coverage-with-tests.info
+
+ lcov --quiet \
+ --remove build/coverage-with-tests.info "$PWD/tests/*" \
+ --rc lcov_branch_coverage=1 \
+ --output-file build/coverage.info
+
+ genhtml --branch-coverage \
+ --demangle-cpp \
+ --legend \
+ --output-directory build/coverage \
+ --title "PSync unit tests" \
+ build/coverage.info
+fi