Fix build with current ndn-cxx and update CI scripts
Change-Id: I766c4679456561d6d7335889b8b9974dc7b94aa6
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index c362297..84c8ae1 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -7,14 +7,27 @@
set -x
if has OSX $NODE_LABELS; then
+ FORMULAE=(boost openssl pkg-config)
brew update
- brew upgrade
- brew install pkg-config boost openssl
+ if [[ -n $TRAVIS ]]; then
+ # travis images come with a large number of brew packages
+ # pre-installed, don't waste time upgrading all of them
+ for FORMULA in "${FORMULAE[@]}"; do
+ brew outdated $FORMULA || brew upgrade $FORMULA
+ done
+ else
+ brew upgrade
+ fi
+ brew install "${FORMULAE[@]}"
brew cleanup
fi
if has Ubuntu $NODE_LABELS; then
sudo apt-get -qq update
- sudo apt-get -qq install build-essential pkg-config libboost-all-dev \
+ sudo apt-get -qy install build-essential pkg-config libboost-all-dev \
libsqlite3-dev libssl-dev
+
+ if [[ $JOB_NAME == *"code-coverage" ]]; then
+ sudo apt-get -qy install gcovr lcov libgd-perl
+ fi
fi
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh
similarity index 96%
rename from .jenkins.d/10-ndn-cxx.sh
rename to .jenkins.d/01-ndn-cxx.sh
index c9e2a63..29a41ea 100755
--- a/.jenkins.d/10-ndn-cxx.sh
+++ b/.jenkins.d/01-ndn-cxx.sh
@@ -44,7 +44,7 @@
./waf configure --color=yes --enable-shared --disable-static --without-osx-keychain
./waf build --color=yes -j${WAF_JOBS:-1}
-sudo env "PATH=$PATH" ./waf install --color=yes
+sudo_preserve_env PATH -- ./waf install --color=yes
popd >/dev/null
popd >/dev/null
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..0c952ec
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+if [[ $JOB_NAME == *"code-coverage" ]]; then
+ COVERAGE="--with-coverage"
+elif [[ -z $DISABLE_ASAN ]]; then
+ ASAN="--with-sanitizer=address"
+fi
+
+# Cleanup
+sudo_preserve_env PATH -- ./waf --color=yes distclean
+
+if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
+ # Configure/build in optimized mode with tests
+ ./waf --color=yes configure --with-tests
+ ./waf --color=yes build -j${WAF_JOBS:-1}
+
+ # Cleanup
+ sudo_preserve_env PATH -- ./waf --color=yes distclean
+
+ # Configure/build in optimized mode without tests
+ ./waf --color=yes configure
+ ./waf --color=yes build -j${WAF_JOBS:-1}
+
+ # Cleanup
+ sudo_preserve_env PATH -- ./waf --color=yes distclean
+fi
+
+# Configure/build in debug mode with tests
+./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE
+./waf --color=yes build -j${WAF_JOBS:-1}
+
+# (tests will be run against debug version)
+
+# Install
+sudo_preserve_env PATH -- ./waf --color=yes install
diff --git a/.jenkins.d/20-ndns.sh b/.jenkins.d/20-ndns.sh
deleted file mode 100755
index db41533..0000000
--- a/.jenkins.d/20-ndns.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-source "$JDIR"/util.sh
-
-set -x
-
-git submodule init
-git submodule sync
-git submodule update
-
-# Cleanup
-sudo ./waf -j1 --color=yes distclean
-
-if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
- # Configure/build in optimized mode with tests
- ./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
- ./waf -j1 --color=yes configure
- ./waf -j1 --color=yes build
-
- # Cleanup
- sudo ./waf -j1 --color=yes distclean
-fi
-
-# Configure/build in debug mode with tests
-if [[ $JOB_NAME == *"code-coverage" ]]; then
- COVERAGE="--with-coverage"
-elif ! has OSX-10.9 $NODE_LABELS && ! has OSX-10.11 $NODE_LABELS; then
- ASAN="--with-sanitizer=address"
-fi
-./waf -j1 --color=yes configure --debug --with-tests $COVERAGE $ASAN
-./waf -j1 --color=yes build
-
-# (tests will be run against debug version)
-
-# Install
-sudo ./waf -j1 --color=yes install
diff --git a/.jenkins.d/30-unit-tests.sh b/.jenkins.d/20-tests.sh
similarity index 91%
rename from .jenkins.d/30-unit-tests.sh
rename to .jenkins.d/20-tests.sh
index e769729..e9c1c85 100755
--- a/.jenkins.d/30-unit-tests.sh
+++ b/.jenkins.d/20-tests.sh
@@ -41,4 +41,8 @@
ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
export ASAN_OPTIONS
-./build/unit-tests $(ut_log_args ndns)
+export BOOST_TEST_BUILD_INFO=1
+export BOOST_TEST_COLOR_OUTPUT=1
+
+# Run unit tests
+./build/unit-tests $(ut_log_args)
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100755
index 0000000..9990760
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+if [[ $JOB_NAME == *"code-coverage" ]]; then
+ gcovr --object-directory=build \
+ --output=build/coverage.xml \
+ --exclude="$PWD/tests" \
+ --root=. \
+ --xml
+
+ # Generate also a detailed HTML output, but using lcov (better results)
+ 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 \
+ --frames \
+ --legend \
+ --output-directory build/coverage \
+ --title "NDNS unit tests" \
+ build/coverage.info
+fi
diff --git a/.jenkins.d/40-coverage.sh b/.jenkins.d/40-coverage.sh
deleted file mode 100755
index 7364c5a..0000000
--- a/.jenkins.d/40-coverage.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-source "$JDIR"/util.sh
-
-set -x
-
-if [[ $JOB_NAME == *"code-coverage" ]]; then
- gcovr --object-directory=build \
- --output=build/coverage.xml \
- --exclude="$PWD/(build|tests)" \
- --root=. \
- --xml
-fi
diff --git a/.jenkins.d/README.md b/.jenkins.d/README.md
index 39fa40b..5813349 100644
--- a/.jenkins.d/README.md
+++ b/.jenkins.d/README.md
@@ -27,7 +27,7 @@
Possible values:
* empty: default build process
- * `code-coverage` (Linux OS is assumed): debug build with tests and code coverage analysis
+ * `code-coverage` (Ubuntu Linux is assumed): debug build with tests and code coverage analysis
* `limited-build`: only a single debug build with tests
- `CACHE_DIR`: the variable defines a path to folder containing cached files from previous builds,
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
index a89bc27..8ddc4ba 100644
--- a/.jenkins.d/util.sh
+++ b/.jenkins.d/util.sh
@@ -16,3 +16,22 @@
set ${saved_xtrace}
return ${ret}
}
+
+sudo_preserve_env() {
+ local saved_xtrace
+ [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
+ set +x
+
+ local vars=()
+ while [[ $# -gt 0 ]]; do
+ local arg=$1
+ shift
+ case ${arg} in
+ --) break ;;
+ *) vars+=("${arg}=${!arg}") ;;
+ esac
+ done
+
+ set ${saved_xtrace}
+ sudo env "${vars[@]}" "$@"
+}