diff options
Diffstat (limited to 'test/integration/framework')
-rw-r--r-- | test/integration/framework | 151 |
1 files changed, 125 insertions, 26 deletions
diff --git a/test/integration/framework b/test/integration/framework index 7dd7c20a7..4003d932c 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -88,11 +88,11 @@ msgdone() { runapt() { msgdebug "Executing: ${CCMD}$*${CDEBUG} " if [ -f ./aptconfig.conf ]; then - APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* - elif [ -f ../aptconfig.conf ]; then - APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* + elif [ -f ../aptconfig.conf ]; then + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* else - LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* + MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* fi } aptconfig() { runapt apt-config $*; } @@ -131,13 +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() { if [ "$1" = 'prefix' ]; then CURRENTTRAP="$2 $CURRENTTRAP" else CURRENTTRAP="$CURRENTTRAP $1" fi - trap "$CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM } setupenvironment() { @@ -177,13 +187,14 @@ 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 echo 'quiet::NoUpdate "true";' >> aptconfig.conf export LC_ALL=C export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" + configcompression '.' 'gz' #'bz2' 'lzma' 'xz' msgdone "info" } @@ -225,12 +236,18 @@ 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)" for ARCH in ${ARCHS}; do - if [ "${ARCH}" != "${DPKGARCH}" ]; then dpkg --add-architecture ${ARCH}; fi + if [ "${ARCH}" != "${DPKGARCH}" ]; then + if ! dpkg --add-architecture ${ARCH}; then + # old-style used e.g. in Ubuntu-P – and as it seems travis + echo "DPKG::options:: \"--foreign-architecture\";" >> aptconfig.conf + echo "DPKG::options:: \"${ARCH}\";" >> aptconfig.conf + fi + fi done if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then # dpkg doesn't really check the version as long as it is fully installed, @@ -241,6 +258,20 @@ configdpkg() { fi } +configcompression() { + while [ -n "$1" ]; do + case "$1" in + '.') echo ".\t.\tcat";; + 'gz') echo "gzip\tgz\tgzip";; + 'bz2') echo "bzip2\tbz2\tbzip2";; + 'lzma') echo "lzma\tlzma\txz --format=lzma";; + 'xz') echo "xz\txz\txz";; + *) echo "$1\t$1\t$1";; + esac + shift + done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf +} + setupsimplenativepackage() { local NAME="$1" local ARCH="$2" @@ -411,6 +442,8 @@ buildaptarchive() { } createaptftparchiveconfig() { + local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')" + COMPRESSORS="${COMPRESSORS%* }" local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')" if [ -z "$ARCHS" ]; then # the pool is empty, so we will operate on faked packages - let us use the configured archs @@ -428,10 +461,10 @@ createaptftparchiveconfig() { echo -n '"; }; Default { - Packages::Compress ". gzip bzip2 lzma xz"; - Sources::Compress ". gzip bzip2 lzma xz"; - Contents::Compress ". gzip bzip2 lzma xz"; - Translation::Compress ". gzip bzip2 lzma xz"; + Packages::Compress "'"$COMPRESSORS"'"; + Sources::Compress "'"$COMPRESSORS"'"; + Contents::Compress "'"$COMPRESSORS"'"; + Translation::Compress "'"$COMPRESSORS"'"; LongDescription "false"; }; TreeDefault { @@ -601,18 +634,27 @@ buildaptarchivefromfiles() { msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…" find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do msgninfo "\t${line} file… " - cat ${line} | gzip > ${line}.gz - 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 + compressfile "$line" "$1" msgdone "info" done generatereleasefiles "$@" } +compressfile() { + cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do + if [ "$compressor" = '.' ]; then + if [ -n "$2" ]; then + touch -d "$2" "$1" + fi + continue + fi + cat "$1" | $command > "${1}.${extension}" + if [ -n "$2" ]; then + touch -d "$2" "${1}.${extension}" + fi + done +} + # can be overridden by testcases for their pleasure getcodenamefromsuite() { echo -n "$1"; } getreleaseversionfromsuite() { true; } @@ -711,22 +753,45 @@ setupaptarchive() { 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 --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE} local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" - gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" --clearsign -o $INRELEASE $RELEASE + $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" } @@ -828,7 +893,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)" \ @@ -905,6 +970,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 |