ci: Enable coverage report and allow unit test output in XML format
Change-Id: I952654aa25d2bdfb5ba1885d1c7570cfdb7e3edf
diff --git a/.jenkins.d/20-ndns.sh b/.jenkins.d/20-ndns.sh
index ee128f5..d2552e7 100755
--- a/.jenkins.d/20-ndns.sh
+++ b/.jenkins.d/20-ndns.sh
@@ -2,7 +2,30 @@
set -x
set -e
-./waf distclean --color=yes
-./waf configure --debug --with-tests --color=yes
-./waf -j1 --color=yes
-sudo ./waf install --color=yes
+COVERAGE=$( python -c "print '--with-coverage --debug' if 'code-coverage' in '$JOB_NAME' else ''" )
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in debug mode
+./waf -j1 --color=yes configure --with-tests --debug
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode without tests
+./waf -j1 --color=yes configure
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode
+./waf -j1 --color=yes configure --with-tests $COVERAGE
+./waf -j1 --color=yes build
+
+# (tests will be run against optimized version)
+
+# Install
+sudo ./waf -j1 --color=yes install
diff --git a/.jenkins.d/30-unit-tests.sh b/.jenkins.d/30-unit-tests.sh
index b05ec4a..4f8248b 100755
--- a/.jenkins.d/30-unit-tests.sh
+++ b/.jenkins.d/30-unit-tests.sh
@@ -8,9 +8,13 @@
IS_OSX=$( python -c "print 'yes' if 'OSX' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
IS_LINUX=$( python -c "print 'yes' if 'Linux' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
-if [ $IS_OSX = "yes" ]; then
+if [[ $IS_OSX == "yes" ]]; then
security unlock-keychain -p "named-data"
fi
# Run unit tests
-./build/unit-tests -l test_suite
+if [[ -n "$XUNIT" ]]; then
+ ./build/unit-tests --log_format=XML --log_sink=build/xunit-report.xml --log_level=all --report_level=no
+else
+ ./build/unit-tests -l test_suite
+fi
diff --git a/.jenkins.d/40-coverage.sh b/.jenkins.d/40-coverage.sh
new file mode 100755
index 0000000..ccbb62e
--- /dev/null
+++ b/.jenkins.d/40-coverage.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+IS_COVR=$( python -c "print 'yes' if 'code-coverage' in '$JOB_NAME' else 'no'" )
+
+if [[ $IS_COVR == "yes" ]]; then
+ BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
+ (cd build && gcovr -x -f $BASE/src -r ../ -o coverage.xml -b ./)
+fi
diff --git a/tests/wscript b/tests/wscript
index fa36e78..25708c0 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -10,28 +10,35 @@
dst = bld.bldnode.make_node("conf-test/anchors")
dst.mkdir()
- bld(features = "subst",
- name = 'test-validator-conf',
- source = '../validator.conf.sample.in',
- target = '../conf-test/validator.conf',
- use = 'validator-sample',
+ bld(features="subst",
+ name='test-validator-conf',
+ source='../validator.conf.sample.in',
+ target='../conf-test/validator.conf',
+ use='validator-sample',
ANCHORPATH='\"anchors/root.cert\"',
RELATION='is-prefix-of',
)
- bld(features = "subst",
- name = 'test-logger-conf',
- source = '../log4cxx.properties.sample.in',
- target = '../conf-test/log4cxx.properties.sample',
- is_copy = True,
- use = 'log4cxx-sample',
+ bld(features="subst",
+ name='test-logger-conf',
+ source='../log4cxx.properties.sample.in',
+ target='../conf-test/log4cxx.properties.sample',
+ is_copy=True,
+ use='log4cxx-sample',
)
+ bld(features='cxx',
+ name='unit-tests-main',
+ target='unit-tests-main',
+ source='main.cpp',
+ defines=['BOOST_TEST_MODULE=NDNS Unit Tests'],
+ use='ndns-objects BOOST')
+
unit_tests = bld.program(
target='../unit-tests',
features='cxx cxxprogram',
- source=bld.path.ant_glob(['**/*.cpp']),
- use='ndns-objects',
+ source=bld.path.ant_glob(['**/*.cpp'], excl=['main.cpp']),
+ use='ndns-objects unit-tests-main BOOST',
install_path=None,
defines='TEST_CONFIG_PATH=\"%s/conf-test\"' %(bld.bldnode)
)