summaryrefslogtreecommitdiff
path: root/test/integration/framework
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/framework')
-rw-r--r--test/integration/framework162
1 files changed, 127 insertions, 35 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 9b01c3161..72c899e32 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -38,7 +38,11 @@ msgtest() {
}
msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
+msgfail() {
+ if [ $# -gt 0 ]; then echo "${CFAIL}FAIL: $*${CNORMAL}" >&2;
+ else echo "${CFAIL}FAIL${CNORMAL}" >&2; fi
+ EXIT_CODE=$((EXIT_CODE+1));
+}
# enable / disable Debugging
MSGLEVEL=${MSGLEVEL:-3}
@@ -56,9 +60,9 @@ if [ $MSGLEVEL -le 2 ]; then
msgpass() { echo -n " ${CPASS}P${CNORMAL}" >&2; }
msgskip() { echo -n " ${CWARNING}S${CNORMAL}" >&2; }
if [ -n "$CFAIL" ]; then
- msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; }
+ msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
else
- msgfail() { echo -n " ###FAILED###" >&2; }
+ msgfail() { echo -n " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
fi
fi
if [ $MSGLEVEL -le 3 ]; then
@@ -114,6 +118,9 @@ gdb() {
echo "gdb: run »$*«"
APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
}
+http() {
+ LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods/http
+}
exitwithstatus() {
# error if we about to overflow, but ...
@@ -124,9 +131,23 @@ exitwithstatus() {
exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
}
+shellsetedetector() {
+ local exit_status=$?
+ if [ "$exit_status" != '0' ]; then
+ echo >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}"
+ if [ "$EXIT_CODE" = '0' ]; then
+ EXIT_CODE="$exit_status"
+ fi
+ fi
+}
+
addtrap() {
- CURRENTTRAP="$CURRENTTRAP $1"
- trap "$CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+ if [ "$1" = 'prefix' ]; then
+ CURRENTTRAP="$2 $CURRENTTRAP"
+ else
+ CURRENTTRAP="$CURRENTTRAP $1"
+ fi
+ trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
}
setupenvironment() {
@@ -135,8 +156,7 @@ setupenvironment() {
msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
BUILDDIRECTORY="${TESTDIRECTORY}/../../build/bin"
test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
- local OLDWORKINGDIRECTORY=$(pwd)
- addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;"
+ addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
cd $TMPWORKINGDIRECTORY
mkdir rootdir aptarchive keys
cd rootdir
@@ -167,7 +187,7 @@ setupenvironment() {
echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
- if ! $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then
+ if ! $(which dpkg) --assert-multi-arch >/dev/null 2>&1; then
echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
fi
echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
@@ -215,7 +235,7 @@ configdpkg() {
echo -n > rootdir/var/lib/dpkg/status
fi
fi
- if $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then
+ if $(which dpkg) --assert-multi-arch >/dev/null 2>&1; then
local ARCHS="$(getarchitectures)"
if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
DPKGARCH="$(dpkg --print-architecture)"
@@ -483,6 +503,7 @@ insertpackage() {
local VERSION="$4"
local DEPENDENCIES="$5"
local PRIORITY="${6:-optional}"
+ local DESCRIPTION="${7}"
local ARCHS=""
for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
@@ -504,11 +525,16 @@ Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
echo "Version: $VERSION
Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
- echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ echo -n 'Description: ' >> $FILE
+ if [ -z "$DESCRIPTION" ]; then
+ echo "an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
YOU did something horribly wrong! They are autogenerated
- und used only by testcases for APT and surf no other propose…
-" >> $FILE
+ und used only by testcases for APT and surf no other propose…" >> $FILE
+ else
+ echo "$DESCRIPTION" >> $FILE
+ fi
+ echo >> $FILE
done
done
}
@@ -589,9 +615,12 @@ buildaptarchivefromfiles() {
cat ${line} | bzip2 > ${line}.bz2
cat ${line} | xz --format=lzma > ${line}.lzma
cat ${line} | xz > ${line}.xz
+ if [ -n "$1" ]; then
+ touch -d "$1" ${line}.gz ${line}.bz2 ${line}.lzma ${line}.xz
+ fi
msgdone "info"
done
- generatereleasefiles
+ generatereleasefiles "$@"
}
# can be overridden by testcases for their pleasure
@@ -683,58 +712,87 @@ setupaptarchive() {
setupflataptarchive
fi
signreleasefiles
- msgninfo "\tSync APT's cache with the archive… "
- aptget update -qq
- msgdone "info"
+ if [ "$1" != '--no-update' ]; then
+ msgninfo "\tSync APT's cache with the archive… "
+ aptget update -qq
+ msgdone "info"
+ fi
}
signreleasefiles() {
local SIGNER="${1:-Joe Sixpack}"
+ local GPG="gpg --batch --yes --no-default-keyring --trustdb-name rootdir/etc/apt/trustdb.gpg"
msgninfo "\tSign archive with $SIGNER key… "
- local SECKEYS=""
+ local REXKEY='keys/rexexpired'
+ local SECEXPIREBAK="${REXKEY}.sec.bak"
+ local PUBEXPIREBAK="${REXKEY}.pub.bak"
+ if [ "${SIGNER}" = 'Rex Expired' ]; then
+ # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
+ # option doesn't exist anymore (and using faketime would add a new obscure dependency)
+ # therefore we 'temporary' make the key not expired and restore a backup after signing
+ cp ${REXKEY}.sec $SECEXPIREBAK
+ cp ${REXKEY}.pub $PUBEXPIREBAK
+ local SECUNEXPIRED="${REXKEY}.sec.unexpired"
+ local PUBUNEXPIRED="${REXKEY}.pub.unexpired"
+ if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
+ cp $SECUNEXPIRED ${REXKEY}.sec
+ cp $PUBUNEXPIRED ${REXKEY}.pub
+ else
+ printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub --secret-keyring ${REXKEY}.sec --command-fd 0 --edit-key "${SIGNER}" >/dev/null 2>&1 || true
+ cp ${REXKEY}.sec $SECUNEXPIRED
+ cp ${REXKEY}.pub $PUBUNEXPIRED
+ fi
+ fi
for KEY in $(find keys/ -name '*.sec'); do
- SECKEYS="$SECKEYS --secret-keyring $KEY"
+ GPG="$GPG --secret-keyring $KEY"
done
- local PUBKEYS=""
for KEY in $(find keys/ -name '*.pub'); do
- PUBKEYS="$PUBKEYS --keyring $KEY"
+ GPG="$GPG --keyring $KEY"
done
for RELEASE in $(find aptarchive/ -name Release); do
- gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg ${RELEASE}
- gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" --clearsign -o "$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" $RELEASE
+ $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE}
+ local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
+ $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
+ # we might have set a specific date for the Release file, so copy it
+ touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg ${INRELEASE}
done
+ if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
+ mv -f $SECEXPIREBAK ${REXKEY}.sec
+ mv -f $PUBEXPIREBAK ${REXKEY}.pub
+ fi
msgdone "info"
}
changetowebserver() {
- if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then
- msgdie 'Need the aptwebserver when passing arguments'
- fi
-
local LOG='/dev/null'
if test -x ${BUILDDIRECTORY}/aptwebserver; then
cd aptarchive
- LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> $LOG > $LOG &
- addtrap "kill $!;"
+ LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1
+ local PID="$(cat aptwebserver.pid)"
+ if [ -z "$PID" ]; then
+ msgdie 'Could not fork aptwebserver successfully'
+ fi
+ addtrap "kill $PID;"
cd - > /dev/null
+ elif [ $# -gt 0 ]; then
+ msgdie 'Need the aptwebserver when passing arguments for the webserver'
elif which weborf > /dev/null; then
- weborf -xb aptarchive/ 2> $LOG > $LOG &
+ weborf -xb aptarchive/ >$LOG 2>&1 &
addtrap "kill $!;"
elif which gatling > /dev/null; then
cd aptarchive
- gatling -p 8080 -F -S 2> $LOG > $LOG &
+ gatling -p 8080 -F -S >$LOG 2>&1 &
addtrap "kill $!;"
cd - > /dev/null
elif which lighttpd > /dev/null; then
echo "server.document-root = \"$(readlink -f ./aptarchive)\"
server.port = 8080
server.stat-cache-engine = \"disable\"" > lighttpd.conf
- lighttpd -t -f lighttpd.conf 2> $LOG > $LOG || msgdie 'Can not change to webserver: our lighttpd config is invalid'
- lighttpd -D -f lighttpd.conf 2> $LOG > $LOG &
+ lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
+ lighttpd -D -f lighttpd.conf >$LOG 2>&1 &
addtrap "kill $!;"
else
- msgdie 'You have to install weborf or lighttpd first'
- return 1
+ msgdie 'You have to build aptwerbserver or install a webserver'
fi
local APTARCHIVE="file://$(readlink -f ./aptarchive)"
for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
@@ -803,7 +861,7 @@ testequalor2() {
echo "$2" > $COMPAREFILE2
shift 2
msgtest "Test for equality OR of" "$*"
- $* 2>&1 1> $COMPAREAGAINST
+ $* >$COMPAREAGAINST 2>&1
(checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
@@ -880,6 +938,40 @@ testmarkedauto() {
aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
+testsuccess() {
+ if [ "$1" = '--nomsg' ]; then
+ shift
+ else
+ msgtest 'Test for successful execution of' "$*"
+ fi
+ local OUTPUT=$(mktemp)
+ addtrap "rm $OUTPUT;"
+ if $@ >${OUTPUT} 2>&1; then
+ msgpass
+ else
+ echo
+ cat $OUTPUT
+ msgfail
+ fi
+}
+
+testfailure() {
+ if [ "$1" = '--nomsg' ]; then
+ shift
+ else
+ msgtest 'Test for failure in execution of' "$*"
+ fi
+ local OUTPUT=$(mktemp)
+ addtrap "rm $OUTPUT;"
+ if $@ >${OUTPUT} 2>&1; then
+ echo
+ cat $OUTPUT
+ msgfail
+ else
+ msgpass
+ fi
+}
+
pause() {
echo "STOPPED execution. Press enter to continue"
local IGNORE