REGTEST: Fix several issues.

Use #!bin/sh more portable shebang.
Support filenames with spaces.
Set HAPROXY_PROGRAM environment variable value to ${PWD}/haproxy.
exit(1) if we could not creat the higher level temporary working directory
or create its sub-directory with mktemp utility.
As defined by POSIX, use six characters for the mktemp template.
This commit is contained in:
Frdric Lcaille 2018-11-29 21:41:42 +01:00 committed by Willy Tarreau
parent 4667773a8a
commit 51e01b56ec

View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/bin/sh
if [ "$1" = "--help" ]; then if [ "$1" = "--help" ]; then
cat << EOF cat << EOF
@ -180,8 +180,8 @@ _version() {
echo "" echo ""
echo "########################## Preparing to run tests ##########################" echo "########################## Preparing to run tests ##########################"
HAPROXY_PROGRAM=${HAPROXY_PROGRAM:-haproxy} HAPROXY_PROGRAM="${HAPROXY_PROGRAM:-${PWD}/haproxy}"
VARNISHTEST_PROGRAM=${VARNISHTEST_PROGRAM:-varnishtest} VARNISHTEST_PROGRAM="${VARNISHTEST_PROGRAM:-varnishtest}"
preparefailed= preparefailed=
if ! [ -x "$(command -v $HAPROXY_PROGRAM)" ]; then if ! [ -x "$(command -v $HAPROXY_PROGRAM)" ]; then
@ -205,12 +205,12 @@ echo "Testing with haproxy version: $HAPROXY_VERSION"
TESTRUNDATETIME="$(date '+%Y-%m-%d_%H-%M-%S')" TESTRUNDATETIME="$(date '+%Y-%m-%d_%H-%M-%S')"
TESTDIR=${TMPDIR:-/tmp}/varnishtest_haproxy TESTDIR="${TMPDIR:-/tmp}"
mkdir -p "$TESTDIR" mkdir -p "$TESTDIR" || exit 1
TESTDIR=$(mktemp -d $TESTDIR/$TESTRUNDATETIME.XXXX) TESTDIR=$(mktemp -d "$TESTDIR/$TESTRUNDATETIME.XXXXXX") || exit 1
export TMPDIR=$TESTDIR export TMPDIR="$TESTDIR"
export HAPROXY_PROGRAM=$HAPROXY_PROGRAM export HAPROXY_PROGRAM="$HAPROXY_PROGRAM"
# Mimic implicit build options from haproxy MakeFile that are present for each target: # Mimic implicit build options from haproxy MakeFile that are present for each target:
@ -300,18 +300,18 @@ fi
if [ $_vtresult != 0 ] if [ $_vtresult != 0 ]
then then
echo "########################## Gathering failed results ##########################" echo "########################## Gathering failed results ##########################"
for i in $(find $TESTDIR/ -type d -name "vtc.*"); export TESTDIR
do find "$TESTDIR" -type d -name "vtc.*" -exec sh -c 'for i; do
cat <<- EOF | tee $TESTDIR/failedtests.log if [ ! -e "$i/LOG" ] ; then continue; fi
$(echo "###### $(cat $i/INFO) ######") cat <<- EOF | tee -a "$TESTDIR/failedtests.log"
$(echo "## test results in: $i") $(echo "###### $(cat "$i/INFO") ######")
$(grep -- ---- $i/LOG) $(echo "## test results in: \"$i\"")
$(grep -- ---- "$i/LOG")
EOF EOF
done done' sh {} +
exit 1 exit 1
else else
# all tests were succesfull, removing tempdir (the last part.) # all tests were succesfull, removing tempdir (the last part.)
rm -d $TESTDIR rmdir "$TESTDIR"
fi fi
exit 0 exit 0