rewrite compressed indexes test to check with all compressors
authorDavid Kalnischkies <david@kalnischkies.de>
Thu, 25 Sep 2014 09:52:41 +0000 (11:52 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Thu, 25 Sep 2014 13:23:14 +0000 (15:23 +0200)
Git-Dch: Ignore

test/integration/framework
test/integration/test-bug-595691-empty-and-broken-archive-files
test/integration/test-compressed-indexes

index ff010a5..7923e23 100644 (file)
@@ -339,6 +339,36 @@ configcompression() {
        done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
 }
 
+forcecompressor() {
+       COMPRESSOR="$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"
+       if [ -e "/bin/${COMPRESSOR}" ]; then
+               echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+       elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
+               echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+       elif [ "${COMPRESSOR}" = 'lzma' ]; then
+               echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
+               COMPRESSOR_CMD='xz --format=lzma'
+       else
+               msgtest 'Test for availability of compressor' "${COMPRESSOR}"
+               msgfail
+       fi
+}
+
 setupsimplenativepackage() {
        local NAME="$1"
        local ARCH="$2"
index 23a6388..aea3402 100755 (executable)
@@ -48,37 +48,8 @@ createemptyfile() {
        rm -f aptarchive/Packages
 }
 
-setupcompressor() {
-       COMPRESSOR="$1"
-       COMPRESSOR_CMD="$1"
-       case $COMPRESSOR in
-       gzip) COMPRESS="gz";;
-       bzip2) COMPRESS="bz2";;
-       lzma) COMPRESS="lzma";;
-       xz) COMPRESS="xz";;
-       esac
-       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\";" > rootdir/etc/apt/apt.conf.d/00compressor
-       if [ -e "/bin/${COMPRESSOR}" ]; then
-               echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
-       elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
-               echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
-       elif [ "${COMPRESSOR}" = 'lzma' ]; then
-               echo "Dir::Bin::xz \"/usr/bin/xz\";" >> rootdir/etc/apt/apt.conf.d/00compressor
-               COMPRESSOR_CMD='xz --format=lzma'
-       else
-               msgtest "Test for availability of compressor" "${COMPRESSOR}"
-               msgfail
-               #exit 1
-       fi
-}
-
 testoverfile() {
-       setupcompressor "$1"
+       forcecompressor "$1"
 
        createemptyfile 'en'
        testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
@@ -100,7 +71,7 @@ E: Some index files failed to download. They have been ignored, or old ones used
 }
 
 testoverhttp() {
-       setupcompressor "$1"
+       forcecompressor "$1"
 
        createemptyfile 'en'
        testaptgetupdate "Get: http://localhost:8080  Packages []
dissimilarity index 63%
index 819cbd3..805ed59 100755 (executable)
-#!/bin/sh
-set -e
-
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
-
-setupenvironment
-configcompression '.' 'xz' 'gz'
-configarchitecture "i386"
-
-buildsimplenativepackage "testpkg" "i386" "1.0"
-setupaptarchive
-
-GOODSHOW="$(aptcache show testpkg)
-"
-GOODPOLICY="$(aptcache policy testpkg)"
-GOODSHOWSRC="$(aptcache showsrc testpkg)
-"
-
-test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
-testequal "$GOODSHOW" aptcache show testpkg
-test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
-testequal "$GOODPOLICY" aptcache policy testpkg
-test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
-testequal "$GOODSHOWSRC" aptcache showsrc testpkg
-
-
-testrun() {
-       local F
-       if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
-               msgtest "Check if all index files are" "${1:-uncompressed}"
-               if [ "$1" = "compressed" ]; then
-                       ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
-                       ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
-                       test -e rootdir/var/lib/apt/lists/*_Packages.xz || F=1
-                       test -e rootdir/var/lib/apt/lists/*_Sources.xz || F=1
-               else
-                       test -e rootdir/var/lib/apt/lists/*_Packages || F=1
-                       test -e rootdir/var/lib/apt/lists/*_Sources || F=1
-                       ! test -e rootdir/var/lib/apt/lists/*_Packages.xz || F=1
-                       ! test -e rootdir/var/lib/apt/lists/*_Sources.xz || F=1
-               fi
-               if [ -n "$F" ]; then
-                       ls -laR rootdir/var/lib/apt/lists/
-                       msgfail
-               else
-                       msgpass
-               fi
-               msgtest "Check if package is downloadable"
-               testsuccess --nomsg aptget install -d testpkg
-               msgtest "\tdeb file is present"; testsuccess --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
-               aptget clean
-               msgtest "\tdeb file is gone"; testfailure --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
-       fi
-       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
-       testequal "$GOODSHOW" aptcache show testpkg
-       testequal "$GOODSHOW" aptcache show testpkg
-       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
-       testequal "$GOODPOLICY" aptcache policy testpkg
-       testequal "$GOODPOLICY" aptcache policy testpkg
-       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
-       testequal "$GOODSHOWSRC" aptcache showsrc testpkg
-       testequal "$GOODSHOWSRC" aptcache showsrc testpkg
-       aptget clean
-       msgtest "Check if the source is aptgetable"
-       testsuccess --nomsg aptget source testpkg
-       msgtest "\tdsc file is present"; testsuccess --nomsg test -f testpkg_1.0.dsc
-       msgtest "\tdirectory is present"; testsuccess --nomsg test -d testpkg-1.0
-       rm -rf testpkg-1.0
-       testequal "$(aptcache show testpkg -o Acquire::Languages=none)
-" aptcache dumpavail
-}
-
-echo 'Acquire::GzipIndexes "false";' > rootdir/etc/apt/apt.conf.d/02compressindex
-msgmsg "File: Test with uncompressed indexes"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
-testrun
-
-rm -rf rootdir/var/lib/apt/lists
-echo 'Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
-
-testsuccess aptget update -o Debug::pkgAcquire::worker=1
-msgmsg "File: Test with compressed indexes"
-testrun "compressed"
-
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
-testrun "compressed"
-
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
-testrun "compressed"
-
-rm rootdir/etc/apt/apt.conf.d/02compressindex
-changetowebserver
-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
-testequal "$GOODPOLICY" aptcache policy testpkg
-
-msgmsg "HTTP: Test with uncompressed indexes"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
-testrun
-
-rm -rf rootdir/var/lib/apt/lists
-echo 'Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
-
-testsuccess aptget update
-msgmsg "HTTP: Test with compressed indexes"
-testrun "compressed"
-
-testsuccess aptget update -o Acquire::Pdiffs=1 -o debug::pkgAcquire::Worker=1 -o debug::pkgAcquire::Auth=1
-msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
-testrun "compressed"
-
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
-testrun "compressed"
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configcompression '.' 'xz' 'bz2' 'lzma' 'gz'
+configarchitecture 'i386'
+
+buildsimplenativepackage 'testpkg' 'i386' '1.0'
+
+buildaptarchive
+setupdistsaptarchive
+# fake a pdiff setup as apt wouldn't try pdiffs otherwise
+find aptarchive -name 'Packages' -o -name 'Sources' | while read file; do
+       mkdir "${file}.diff"
+       PATCHINDEX="${file}.diff/Index"
+       echo 'SHA1-Current: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 0
+SHA1-History:
+ adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 33053002 2010-08-18-2013.28
+ ecfd1b19e793491b1c6ea123eabdcd9f32e592fc 33053001 2010-08-18-2013.29
+SHA1-Patches:
+ abc1fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
+ dfe3444ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.29' > $PATCHINDEX
+done
+generatereleasefiles
+signreleasefiles
+
+testrun() {
+       local F
+       msgtest 'Check if all index files are' "${1:-uncompressed}"
+       if [ "$1" = 'compressed' ]; then
+               ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+               ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+               ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
+               test -e rootdir/var/lib/apt/lists/*_Packages.${COMPRESS} || F=1
+               test -e rootdir/var/lib/apt/lists/*_Sources.${COMPRESS} || F=1
+               test -e rootdir/var/lib/apt/lists/*_Translation-en.${COMPRESS} || F=1
+               # there is no point in trying pdiff if we have compressed indexes
+               # as we can't patch compressed files (well, we can, but what is the point?)
+               ! test -e rootdir/var/lib/apt/lists/*.IndexDiff || F=1
+       else
+               # clear the faked pdiff indexes so the glob below works
+               rm -f rootdir/var/lib/apt/lists/*.IndexDiff
+               test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+               test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+               test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
+               ! test -e rootdir/var/lib/apt/lists/*_Packages.* || F=1
+               ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
+               ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
+       fi
+       if [ -n "$F" ]; then
+               ls -laR rootdir/var/lib/apt/lists/
+               msgfail
+       else
+               msgpass
+       fi
+       msgtest 'Check if package is downloadable'
+       testsuccess --nomsg aptget download testpkg
+       msgtest '\tdeb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
+       rm testpkg_1.0_i386.deb
+       testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  testpkg
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst testpkg (1.0 unstable [i386])
+Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s
+       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+       testequal "$GOODSHOW" aptcache show testpkg
+       testequal "$GOODSHOW" aptcache show testpkg
+       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+       testequal "$GOODPOLICY" aptcache policy testpkg
+       testequal "$GOODPOLICY" aptcache policy testpkg
+       rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+       testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+       testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+       aptget clean
+       msgtest 'Check if the source is aptgetable'
+       testsuccess --nomsg aptget source testpkg
+       msgtest '\tdsc file is present'; testsuccess --nomsg test -f testpkg_1.0.dsc
+       msgtest '\tdirectory is present'; testsuccess --nomsg test -d testpkg-1.0
+       rm -rf testpkg-1.0*
+       testequal "$(aptcache show testpkg -o Acquire::Languages=none)
+" aptcache dumpavail
+}
+
+echo 'Debug::pkgAcquire::worker "true";
+debug::pkgAcquire::Auth "true";
+Debug::pkgAcquire::Diffs "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
+
+testovermethod() {
+       forcecompressor $2
+
+       for INDEX in 'false' 'true'; do
+               rm -rf rootdir/var/lib/apt/lists
+               echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
+               local INDCOMP
+               if [ "$INDEX" = 'false' ]; then
+                       INDCOMP='uncompressed'
+               else
+                       INDCOMP='compressed'
+               fi
+
+               testsuccess aptget update
+               msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes"
+               testrun "$INDCOMP"
+
+               testsuccess aptget update -o Acquire::Pdiffs=1
+               msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged with pdiffs)"
+               testrun "$INDCOMP"
+
+               testsuccess aptget update -o Acquire::Pdiffs=0
+               msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged without pdiffs)"
+               testrun "$INDCOMP"
+
+               rm rootdir/etc/apt/apt.conf.d/02compressindex
+       done
+}
+
+testsuccess aptget update
+GOODSHOW="$(aptcache show testpkg)
+"
+test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
+testequal "$GOODSHOW" aptcache show testpkg
+GOODSHOWSRC="$(aptcache showsrc testpkg)
+"
+test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
+testequal "$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 'policy is broken'
+testequal "$GOODPOLICY" aptcache policy testpkg
+
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done
+
+changetowebserver
+rm -rf rootdir/var/lib/apt/lists
+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 'policy is broken'
+testequal "$GOODPOLICY" aptcache policy testpkg
+
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done