1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/bin/bash
. /etc/apache2/envvars
set -xeu
set -o pipefail
export LANG=C
export PATH=/usr/lib/ccache:$PATH
# set to "-v t/modules/ext_filter.t ..." to run only a few test, but verbose
TESTS=""
TESTUSER=tuser
# The test framework assumes localhost resolves exclusively to 127.0.0.1
# (and not to ::1). So remove 'localhost' from the ::1 entry.
perl -p -i -e ' if (/^\s*::1\s+/) { s/\s+localhost\s+/ /g }' /etc/hosts
useradd --user-group --system --create-home -s /bin/bash $TESTUSER
cp -a debian/perl-framework $AUTOPKGTEST_TMP
cd $AUTOPKGTEST_TMP/perl-framework
export HARNESS_VERBOSE=1
run_tests () {
local MPM=$1
local PORT_OFFSET=${2:-0}
local WORKDIR=$AUTOPKGTEST_TMP/perl-framework-$MPM
local LOG=$AUTOPKGTEST_TMP/testlog.$MPM
echo =============Running-with-${MPM}==========
# Create isolated working directory for this MPM
cp -a $AUTOPKGTEST_TMP/perl-framework $WORKDIR
cd $WORKDIR
rm -f apache2.conf.debian
cp /etc/apache2/apache2.conf apache2.conf.debian
cat /etc/apache2/mods-available/$MPM.load >> apache2.conf.debian
ls /etc/apache2/mods-available/*.load | grep -v mpm_ | xargs cat >> apache2.conf.debian
# these are only for tests and don't have a .load file
for m in bucketeer case_filter case_filter_in ; do
echo "LoadModule ${m}_module /usr/lib/apache2/modules/mod_${m}.so" >> apache2.conf.debian
done
# need TypesConfig from mime.conf for t/modules/filter.t
cat /etc/apache2/mods-available/mime.conf >> apache2.conf.debian
echo "Servername localhost" >> apache2.conf.debian
make clean || true
perl -p -i -e 's,^Include,#Include,' apache2.conf.debian
chown -R $TESTUSER: $WORKDIR
su $TESTUSER -c "perl Makefile.PL -apxs /usr/bin/apxs2 -httpd_conf $PWD/apache2.conf.debian -port \$((8529 + $PORT_OFFSET))" \
|| return 1
su $TESTUSER -c "t/TEST $TESTS" | tee $LOG
if ! grep -E "^Files=[0-9]+, Tests=[0-9]+" $LOG ; then
echo "Message about Files/Tests not found in $LOG" >&2
return 1
fi
if ! grep -E "^Result: PASS" $LOG ; then
echo "PASS message not found in $LOG" >&2
return 1
fi
if grep -E "^Result: FAIL" $LOG ; then >&2
echo "Test suite failed"
return 1
fi
if grep -E "server dumped core" $LOG ; then >&2
echo "segfault detected"
return 1
fi
return 0
}
NCPUS=$(nproc)
if [ "$NCPUS" -ge 3 ]; then
echo "Running tests in parallel ($NCPUS CPUs available)"
run_tests mpm_prefork 0 &
pid1=$!
run_tests mpm_worker 100 &
pid2=$!
run_tests mpm_event 200 &
pid3=$!
fail=0
wait $pid1 || fail=1
wait $pid2 || fail=1
wait $pid3 || fail=1
exit $fail
else
echo "Running tests sequentially ($NCPUS CPUs available)"
run_tests mpm_prefork
run_tests mpm_worker
run_tests mpm_event
fi
|