# Creating temp directory
info "Creating temporary working directory"
-temp_dir=`mktemp -d ldns-dist-XXXXXX`
-doc_dir=`mktemp -d ldns-dist-XXXXXX`
+temp_dir=$(mktemp -d ldns-dist-XXXXXX)
+doc_dir=$(mktemp -d ldns-dist-XXXXXX)
info "Directory '$temp_dir' created."
-cd $temp_dir
+cd "$temp_dir"
info "Exporting source from GIT"
- git clone git://git.nlnetlabs.nl/ldns/ || error_cleanup "git command failed"
+ git clone https://github.com/NLnetLabs/ldns.git || error_cleanup "git command failed"
cd ldns || error_cleanup "LDNS not exported correctly from git"
git checkout "$CHECKOUT" || error_cleanup "Could not checkout $CHECKOUT"
git submodule update --init || error_cleanup "Could not update submodules"
. common.sh
# find tpkg
- if test -x "$(command -v tpkg 2>&1)"; then
- TPKG=tpkg
- else
- TPKG="$1"
- if [ -z "$TPKG" ]
- then
- TPKG="$HOME/repos/tpkg/tpkg"
- fi
-
+ if [ -z "$TPKG" -o ! -x "$TPKG" ]
+ then
- if [ -x tpkg/tpkg ] ; then TPKG=`pwd`/tpkg/tpkg
- elif [ -x test/tpkg/tpkg ] ; then TPKG=`pwd`/test/tpkg/tpkg
- elif which tpkg > /dev/null ; then TPKG=`which tpkg`
++ if [ -x tpkg/tpkg ] ; then TPKG="$(pwd)/tpkg/tpkg"
++ elif [ -x test/tpkg/tpkg ] ; then TPKG="$(pwd)/test/tpkg/tpkg"
++ elif command -v tpkg > /dev/null; then TPKG="$(command -v tpkg)"
+ else
+ TPKG=$1
+ if [ -z "$TPKG" ]
+ then
+ TPKG=$HOME/repos/tpkg/tpkg
+ echo Did not find tpkg program!
+ exit -1
+ fi
+ fi
fi
+is_freebsd=$(uname -s 2>&1 | grep -i -c 'freebsd')
test_tool_avail "dig"
-echo start the test at `date` in `pwd`
-[ "$1" = "clean" -o "$2" = "clean" ] && $TPKG clean
+echo start the test at "$(date)" in "$(pwd)"
+[ "$1" = "clean" ] || [ "$2" = "clean" ] && $TPKG clean
$TPKG -a ../.. fake 01-compile.tpkg
-$TPKG -a ../.. fake 02-lint.tpkg # Works only on FreeBSD really
+
+# Works only on FreeBSD really
+if [[ "$is_freebsd" -ne 0 ]]; then
+ $TPKG -a ../.. fake 02-lint.tpkg
+fi
+
$TPKG -a ../.. fake 07-compile-examples.tpkg
$TPKG -a ../.. fake 16-compile-builddir.tpkg
$TPKG -a ../.. fake 30-load-pyldns.tpkg
NO_REGRESSION=1
fi
-if [ -z "$TPKG" -o ! -x "$TPKG" ]
+if [ -z "$TPKG" ] || [ ! -x "$TPKG" ]
then
- if command -v tpkg > /dev/null ; then TPKG="$(command -v tpkg)"
- elif [ -x "$HOME/bin/tpkg" ] ; then TPKG="$HOME/bin/tpkg"
- elif [ -x "$HOME/local/bin/tpkg" ]; then TPKG="$HOME/local/bin/tpkg"
- elif [ -x /home/tpkg/bin/tpkg ] ; then TPKG=/home/tpkg/bin/tpkg
- elif [ -x ../tpkg/tpkg ] ; then TPKG=../tpkg/tpkg
- if [ -x tpkg/tpkg ] ; then TPKG=`pwd`/tpkg/tpkg
- elif [ -x test/tpkg/tpkg ] ; then TPKG=`pwd`/test/tpkg/tpkg
- elif which tpkg > /dev/null ; then TPKG=`which tpkg`
++ if [ -x tpkg/tpkg ] ; then TPKG="$(pwd)/tpkg/tpkg"
++ elif [ -x test/tpkg/tpkg ] ; then TPKG="$(pwd)/test/tpkg/tpkg"
++ elif command -v tpkg > /dev/null; then TPKG="$(command -v tpkg)"
else
echo Did not find tpkg program!
- exit -1
+ exit 255 # Shell can only return 0-255
fi
fi
+
# RUN THE TESTS
-for tests in $BUILD_DIR/test/*.tpkg
+for tests in "$BUILD_DIR"/test/*.tpkg
do
- TESTFN=`basename $tests`
- TESTNR=`echo $TESTFN | sed 's/-.*$//g'`
- [ ! -z "$ONLY_TEST" -a x$ONLY_TEST != x$TESTNR ] && continue
- case $TESTNR in
+ TESTFN="$(basename "$tests")"
+ TESTNR="$(echo "$TESTFN" | sed 's/-.*$//g')"
+ [ -n "$ONLY_TEST" ] && [ x"$ONLY_TEST" != x"$TESTNR" ] && continue
+ case "$TESTNR" in
[3-5][0-9]*) [ $NO_REGRESSION = 1 ] && continue
;;
esac
;;
32) # No backwards compatibility regression testing
# when .so had major version bumb.
- chmod +x $BUILD_DIR/packaging/ldns-config
- BINAPI=`$BUILD_DIR/packaging/ldns-config --libversion`
+ chmod +x "$BUILD_DIR/packaging/ldns-config"
+ BINAPI=$("$BUILD_DIR/packaging/ldns-config" --libversion)
[ "x${BINAPI#*.}" = "x0.0" ] && continue
esac
- $TPKG -b $BUILD_DIR/test -a $BUILD_DIR exe $TESTFN
+ $TPKG -b "$BUILD_DIR/test" -a "$BUILD_DIR" exe "$TESTFN"
done
- # -----------------------------------------------------------------------------
- # ---- Testing part
- #
- ( cd test; $TPKG -q -n "$(find ./ -name 'result.*' -printf "%f\n" | wc -l)" report >/dev/null )
-
- # -----------------------------------------------------------------------------
- # ---- Reusable reporting part
- #
- if test "$?" -eq "0"; then STATUS="pass"; else STATUS="FAIL"; fi
- CI_ID=2
-
- REPOS=$(basename "$(pwd)")
- REPOS=${REPOS%.git}
- CI_URI="${CI_PROJECT_URL}/builds/${CI_BUILD_ID}"
- while [ $# -ge 1 ]
- do
- echo "Sending mail to $1... ($# >= 1)"
- (
- git log -1 --format="From %H %ad%nFrom: %an <%ae>"
- BRANCH=$(
- for W in $( git log -1 --format=%d | tr "()," " " )
- do echo "$W"
- done | grep -v HEAD | head -1
- )
- BRANCH="${BRANCH#origin/}"
- echo "X-Git-Refname: $BRANCH"
- if [ -z "$BRANCH" ] || [ "$BRANCH" = "master" ]
- then
- BRANCH=""
- else
- BRANCH="/$BRANCH"
- fi
- git log -1 --format="Subject: [git: $REPOS$BRANCH][$STATUS] %s"
- echo "To: $1"
- echo "Date: $(LC_ALL=C date '+%a, %e %b %Y %T %z (%Z)')"
- echo "X-Git-Repository: $REPOS"
- git log -2 --format="X-Git-Oldrev: %H"
- git log -1 --format="X-Git-Newrev: %H"
- echo
- uname -a
- echo
- echo "$CI_URI"
- echo
-
- # -------------------------------------------------------------
- # ---- Repository specific reporting part
- # ----
- ( cd test; $TPKG report )
- # ----
- # -------------------------------------------------------------
-
-
- ) | sendmail "$1"
- shift
- done
- test "$STATUS" = "pass"
+ cd test
-exec $TPKG -n -1 r
-
++exec $TPKG -n -1 r