ci: sync jenkins scripts with NFD
Change-Id: I43689bcf51bbe7a1c3118d8b0c226b56077fb4ed
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index 549258a..4a4db28 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -4,17 +4,18 @@
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
+set -x
+
if has OSX $NODE_LABELS; then
- set -x
brew update
brew upgrade
- brew install boost pkg-config cryptopp
+ brew install boost pkg-config cryptopp openssl
brew cleanup
fi
if has Ubuntu $NODE_LABELS; then
- set -x
sudo apt-get -qq update
sudo apt-get -qq install build-essential pkg-config libboost-all-dev \
- libcrypto++-dev libsqlite3-dev libpcap-dev
+ libcrypto++-dev libsqlite3-dev libssl-dev \
+ libpcap-dev
fi
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh
similarity index 83%
rename from .jenkins.d/10-ndn-cxx.sh
rename to .jenkins.d/01-ndn-cxx.sh
index d22bfb6..e5f7585 100755
--- a/.jenkins.d/10-ndn-cxx.sh
+++ b/.jenkins.d/01-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/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..8886aca
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+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
+
+ # 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="" # TODO add code coverage support
+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/20-build.sh b/.jenkins.d/20-build.sh
deleted file mode 100755
index d96c4bd..0000000
--- a/.jenkins.d/20-build.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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
-
-# Configure/build in release mode without tests
-./waf -j1 --color=yes configure
-./waf -j1 --color=yes build
-
-# Cleanup
-sudo ./waf -j1 --color=yes distclean
-
-# Configure/build in debug mode with tests
-if [[ "$JOB_NAME" == *"code-coverage" ]]; then
- COVERAGE="" # TODO add code coverage support
-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)
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
new file mode 100755
index 0000000..216e89f
--- /dev/null
+++ b/.jenkins.d/20-tests.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+# Prepare environment
+rm -Rf ~/.ndn
+
+BOOST_VERSION=$(python -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);")
+
+ut_log_args() {
+ ((ut_count+=1))
+ if (( BOOST_VERSION >= 106200 )); then
+ echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-report-${ut_count}.xml
+ else
+ if [[ -n $XUNIT ]]; then
+ echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \
+ --log_format2=XML --log_sink2=build/xunit-report-${ut_count}.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
+
+# Run unit tests
+./build/unit-tests $(ut_log_args)
+
+unset ut_count
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100755
index 0000000..fc3cbc0
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+# TODO add code coverage support
+if false && [[ $JOB_NAME == *"code-coverage" ]]; then
+ gcovr --object-directory=build \
+ --output=build/coverage.xml \
+ --filter="$PWD/(core|tools)" \
+ --root=. \
+ --xml
+fi
diff --git a/.jenkins.d/30-tests.sh b/.jenkins.d/30-tests.sh
deleted file mode 100755
index 19ed25f..0000000
--- a/.jenkins.d/30-tests.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-set -x
-set -e
-
-rm -rf ~/.ndn
-
-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 -l test_suite
diff --git a/.jenkins.d/README.md b/.jenkins.d/README.md
index 1d4d3e4..386e2db 100644
--- a/.jenkins.d/README.md
+++ b/.jenkins.d/README.md
@@ -28,3 +28,7 @@
* empty: default build process
* `code-coverage` (Linux OS is assumed): build process with code coverage analysis
+ * `limited-build`: only a single build with tests
+
+- `CACHE_DIR`: the variable defines a path to folder containing cached files from previous builds,
+ e.g., a compiled version of ndn-cxx library. If not set, `/tmp` is used.
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
old mode 100755
new mode 100644
index 81c8931..a89bc27
--- 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}
}