Enabling jenkins code coverage
Change-Id: If69a83ffcf0450ac06f7dab17bf862e36aef37ed
Refs: #3434
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
new file mode 100755
index 0000000..c32219b
--- /dev/null
+++ b/.jenkins.d/00-deps.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+if has OSX $NODE_LABELS; then
+ if has OSX-10.8 $NODE_LABELS; then
+ EXTRA_FLAGS=--c++11
+ fi
+
+ set -x
+ brew update
+ brew upgrade
+ brew install boost pkg-config cryptopp $EXTRA_FLAGS
+ brew cleanup
+fi
+
+if has Ubuntu $NODE_LABELS; then
+ BOOST_PKG=libboost-all-dev
+ if has Ubuntu-12.04 $NODE_LABELS; then
+ BOOST_PKG=libboost1.48-all-dev
+ fi
+
+ set -x
+ sudo apt-get update -qq -y
+ sudo apt-get -qq -y install build-essential pkg-config $BOOST_PKG \
+ libcrypto++-dev libsqlite3-dev
+fi
diff --git a/.jenkins.d/01-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh
new file mode 100755
index 0000000..2bc46fd
--- /dev/null
+++ b/.jenkins.d/01-ndn-cxx.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+pushd ${CACHE_DIR:-/tmp} >/dev/null
+
+INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
+
+sudo rm -Rf ndn-cxx-latest
+
+git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
+
+LATEST_VERSION=$((cd ndn-cxx-latest && git rev-parse HEAD) 2>/dev/null || echo UNKNOWN)
+
+if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
+ sudo rm -Rf ndn-cxx
+ mv ndn-cxx-latest ndn-cxx
+else
+ sudo rm -Rf ndn-cxx-latest
+fi
+
+sudo rm -Rf /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib/libndn-cxx*
+sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
+
+pushd ndn-cxx >/dev/null
+
+./waf configure -j1 --color=yes --enable-shared --disable-static --without-osx-keychain
+./waf -j1 --color=yes
+sudo ./waf install -j1 --color=yes
+
+popd >/dev/null
+popd >/dev/null
+
+if has Linux $NODE_LABELS; then
+ sudo ldconfig
+elif has FreeBSD $NODE_LABELS; then
+ sudo ldconfig -a
+fi
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..4fef69c
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+git submodule init
+git submodule sync
+git submodule update
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode with tests and precompiled headers
+./waf -j1 --color=yes configure --with-tests
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode without tests and with precompiled headers
+./waf -j1 --color=yes configure
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+./waf -j1 --color=yes configure --with-tests
+./waf -j1 --color=yes build
+
+# (tests will be run against debug version)
+
+# Install
+sudo ./waf -j1 --color=yes install
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
new file mode 100755
index 0000000..bb1cf63
--- /dev/null
+++ b/.jenkins.d/20-tests.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+# Prepare environment
+rm -Rf ~/.ndn
+
+if has OSX $NODE_LABELS; then
+ echo "Unlocking OSX Keychain"
+ security unlock-keychain -p "named-data"
+fi
+
+ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
+
+# Run unit tests
+if [[ -n "$XUNIT" ]]; then
+ ./build/unit-tests --log_level=all -- --log_format2=XML --log_sink2=build/xunit-report.xml
+else
+ ./build/unit-tests -l test_suite
+fi
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100644
index 0000000..a00f8f1
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+if [[ "$JOB_NAME" == *"code-coverage" ]]; then
+ BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
+ (cd build && gcovr -x -f $BASE/core -f $BASE/daemon -f $BASE/rib -r ../ -o coverage.xml ./)
+fi
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
new file mode 100755
index 0000000..81c8931
--- /dev/null
+++ b/.jenkins.d/util.sh
@@ -0,0 +1,9 @@
+has() {
+ local p=$1
+ shift
+ local x
+ for x in "$@"; do
+ [[ "${x}" == "${p}" ]] && return 0
+ done
+ return 1
+}