From 912a61312a0463b46d6560756c89146f59daaab6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 3 Jan 2016 22:39:46 +0100 Subject: tests: try to pick up compressors from config automatically Less hardcoding should help while introducing new compressors. Git-Dch: Ignore --- test/integration/framework | 22 ++++++++++++---------- .../test-bug-595691-empty-and-broken-archive-files | 4 ++-- test/integration/test-compressed-indexes | 12 ++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 004d24417..e2d545ec2 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -95,7 +95,7 @@ msgfail() { if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2; else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi if [ -n "$APT_DEBUG_TESTS" ]; then - $SHELL + APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" $SHELL fi EXIT_CODE=$((EXIT_CODE+1)); } @@ -526,7 +526,6 @@ configcompression() { 'gz') printf "gzip\tgz\tgzip\n";; 'bz2') printf "bzip2\tbz2\tbzip2\n";; 'lzma') printf "lzma\tlzma\txz --format=lzma\n";; - 'xz') printf "xz\txz\txz\n";; *) printf "$1\t$1\t$1\n";; esac shift @@ -550,21 +549,18 @@ confighashes() { } forcecompressor() { COMPRESSOR="$1" + COMPRESS="$1" COMPRESSOR_CMD="$1" case $COMPRESSOR in gzip) COMPRESS='gz';; bzip2) COMPRESS='bz2';; - lzma) COMPRESS='lzma';; - xz) COMPRESS='xz';; - *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";; esac local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor" echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; }; -Dir::Bin::uncompressed \"/does/not/exist\"; -Dir::Bin::gzip \"/does/not/exist\"; -Dir::Bin::bzip2 \"/does/not/exist\"; -Dir::Bin::lzma \"/does/not/exist\"; -Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE" +Dir::Bin::uncompressed \"/does/not/exist\";" > "$CONFFILE" + for COMP in $(aptconfig dump APT::Compressor --format '%t %v%n' | sed -n 's#^Name \([^.].\+\)$#\1#p'); do + echo "Dir::Bin::${COMP} \"/does/not/exist\";" + done >> "$CONFFILE" if [ -e "/bin/${COMPRESSOR}" ]; then echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE" elif [ -e "/usr/bin/${COMPRESSOR}" ]; then @@ -1828,6 +1824,12 @@ listcurrentlistsdirectory() { done } | sort } +forallsupportedcompressors() { + for COMP in $(aptconfig dump 'APT::Compressor' --format '%f%n' | cut -d':' -f 5 | uniq); do + if [ -z "$COMP" -o "$COMP" = '.' -o "$COMP" = 'lz4' ]; then continue; fi + "$@" "$COMP" + done +} ### convenience hacks ### mkdir() { diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files index c216918c5..c329b76d2 100755 --- a/test/integration/test-bug-595691-empty-and-broken-archive-files +++ b/test/integration/test-bug-595691-empty-and-broken-archive-files @@ -76,9 +76,9 @@ W: Failed to fetch store:$(readlink -f rootdir/var/lib/apt/lists/partial/localho E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http" } -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done +forallsupportedcompressors testoverfile # do the same again with http instead of file changetowebserver -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done +forallsupportedcompressors testoverhttp diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes index 49ffc4a8a..b97e1244b 100755 --- a/test/integration/test-compressed-indexes +++ b/test/integration/test-compressed-indexes @@ -5,7 +5,7 @@ TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" setupenvironment -configcompression '.' 'xz' 'bz2' 'lzma' 'gz' +configcompression '.' $(aptconfig dump APT::Compressor --format '%t %v%n' | sed -n 's#^Extension \.\(.*\)$#\1#p') configarchitecture 'i386' buildsimplenativepackage 'testpkg' 'i386' '1.0' @@ -146,7 +146,7 @@ testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg GOODPOLICY="$(aptcache policy testpkg)" test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'file policy is broken' testsuccessequal "$GOODPOLICY" aptcache policy testpkg -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done +forallsupportedcompressors testovermethod 'file' rewritesourceslist "copy://${TMPWORKINGDIRECTORY}/aptarchive" rm -rf rootdir/var/lib/apt/lists @@ -154,7 +154,7 @@ testsuccess aptget update GOODPOLICY="$(aptcache policy testpkg)" test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 copy:/' | wc -l) -eq 4 || msgdie 'copy policy is broken' testsuccessequal "$GOODPOLICY" aptcache policy testpkg -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'copy' $COMPRESSOR; done +forallsupportedcompressors testovermethod 'copy' changetowebserver rm -rf rootdir/var/lib/apt/lists @@ -162,7 +162,7 @@ testsuccess aptget update GOODPOLICY="$(aptcache policy testpkg)" test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'http policy is broken' testsuccessequal "$GOODPOLICY" aptcache policy testpkg -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done +forallsupportedcompressors testovermethod 'http' changetohttpswebserver rm -rf rootdir/var/lib/apt/lists @@ -170,7 +170,7 @@ testsuccess aptget update GOODPOLICY="$(aptcache policy testpkg)" test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 https://' | wc -l) -eq 4 || msgdie 'https policy is broken' testsuccessequal "$GOODPOLICY" aptcache policy testpkg -for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'https' $COMPRESSOR; done +forallsupportedcompressors testovermethod 'https' changetocdrom 'Debian APT Testdisk 0.8.15' rm -rf rootdir/var/lib/apt/lists @@ -178,4 +178,4 @@ testsuccess aptcdrom add