build: Update build scripts
Change-Id: Ifad7ff5004a4dede8beec348e9920453fc74449d
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index 36fcc7e..765338d 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -4,26 +4,18 @@
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
- set -x
+if has OSX $NODE_LABELS; then
brew update
brew upgrade
- brew install boost pkg-config cryptopp log4cxx $EXTRA_FLAGS
+ brew install boost pkg-config cryptopp openssl log4cxx
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 liblog4cxx10-dev
+ sudo apt-get -qq update
+ sudo apt-get -qq install build-essential pkg-config libboost-all-dev \
+ libcrypto++-dev libsqlite3-dev libssl-dev \
+ liblog4cxx10-dev
fi
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/10-ndn-cxx.sh
index d22bfb6..e5f7585 100755
--- a/.jenkins.d/10-ndn-cxx.sh
+++ b/.jenkins.d/10-ndn-cxx.sh
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
-set -x
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
-pushd /tmp >/dev/null
+set -x
+
+pushd "${CACHE_DIR:-/tmp}" >/dev/null
INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
@@ -28,9 +29,9 @@
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
+./waf -j1 --color=yes configure --enable-shared --disable-static --without-osx-keychain
+./waf -j1 --color=yes build
+sudo ./waf -j1 --color=yes install
popd >/dev/null
popd >/dev/null
diff --git a/.jenkins.d/20-ndns.sh b/.jenkins.d/20-ndns.sh
index 1d9ee2a..b47b93b 100755
--- a/.jenkins.d/20-ndns.sh
+++ b/.jenkins.d/20-ndns.sh
@@ -1,41 +1,44 @@
#!/usr/bin/env bash
-set -x
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
-# Cleanup
-sudo ./waf -j1 --color=yes distclean
+set -x
-# Configure/build in debug mode
-./waf -j1 --color=yes configure --with-tests --debug
-./waf -j1 --color=yes build
+git submodule init
+git submodule sync
+git submodule update
# Cleanup
sudo ./waf -j1 --color=yes distclean
-# Configure/build in optimized mode without tests
-./waf -j1 --color=yes configure
-./waf -j1 --color=yes build
+if [[ "$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
+ # Cleanup
+ sudo ./waf -j1 --color=yes distclean
-# Configure/build in debug mode
+ # 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
+./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
-
-if has Linux $NODE_LABELS; then
- sudo ldconfig
-elif has FreeBSD $NODE_LABELS; then
- sudo ldconfig -a
-fi
diff --git a/.jenkins.d/30-unit-tests.sh b/.jenkins.d/30-unit-tests.sh
index 4d3a8b3..e769729 100755
--- a/.jenkins.d/30-unit-tests.sh
+++ b/.jenkins.d/30-unit-tests.sh
@@ -1,21 +1,44 @@
#!/usr/bin/env bash
-set -x
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
+set -x
+
# Prepare environment
rm -Rf ~/.ndn
if has OSX $NODE_LABELS; then
- echo "Unlocking OSX Keychain"
- security unlock-keychain -p "named-data"
+ security unlock-keychain -p named-data
fi
-# Run unit tests
-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
+ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
+
+BOOST_VERSION=$(python -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);")
+
+ut_log_args() {
+ if (( BOOST_VERSION >= 106200 )); then
+ echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-${1:-report}.xml
+ else
+ if [[ -n $XUNIT ]]; then
+ echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \
+ --log_format2=XML --log_sink2=build/xunit-${1:-report}.xml
+ else
+ echo --log_level=test_suite
+ fi
+ fi
+}
+
+ASAN_OPTIONS="color=always"
+ASAN_OPTIONS+=":detect_leaks=false"
+ASAN_OPTIONS+=":detect_stack_use_after_return=true"
+ASAN_OPTIONS+=":check_initialization_order=true"
+ASAN_OPTIONS+=":strict_init_order=true"
+ASAN_OPTIONS+=":detect_invalid_pointer_pairs=1"
+ASAN_OPTIONS+=":detect_container_overflow=false"
+ASAN_OPTIONS+=":strict_string_checks=true"
+ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
+export ASAN_OPTIONS
+
+./build/unit-tests $(ut_log_args ndns)
diff --git a/.jenkins.d/40-coverage.sh b/.jenkins.d/40-coverage.sh
index e6ecdf3..7364c5a 100755
--- a/.jenkins.d/40-coverage.sh
+++ b/.jenkins.d/40-coverage.sh
@@ -1,11 +1,15 @@
#!/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/src -r ../ -o coverage.xml -b ./)
+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/util.sh b/.jenkins.d/util.sh
index 81c8931..a89bc27 100644
--- a/.jenkins.d/util.sh
+++ b/.jenkins.d/util.sh
@@ -1,9 +1,18 @@
has() {
+ local saved_xtrace
+ [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
+ set +x
+
local p=$1
shift
- local x
- for x in "$@"; do
- [[ "${x}" == "${p}" ]] && return 0
+ local i ret=1
+ for i in "$@"; do
+ if [[ "${i}" == "${p}" ]]; then
+ ret=0
+ break
+ fi
done
- return 1
+
+ set ${saved_xtrace}
+ return ${ret}
}