X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/61153c284c832a0d0f7faecd9ad96f6cd9591c64..5da51e0e2da3f055306562d38103b06a23d81719:/test/integration/test-bug-595691-empty-and-broken-archive-files 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 2f127221a..d71bd2ce5 100755 --- a/test/integration/test-bug-595691-empty-and-broken-archive-files +++ b/test/integration/test-bug-595691-empty-and-broken-archive-files @@ -1,91 +1,64 @@ #!/bin/sh set -e -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" setupenvironment configarchitecture "i386" buildaptarchive +touch aptarchive/Packages setupflataptarchive -testaptgetupdate() { - aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true - sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff - GIVEN="$1" - shift - msgtest "Test for correctness of" "apt-get update with $*" - if [ -z "$GIVEN" ]; then - echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail - else - echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail - fi - rm testaptgetupdate.diff +failureupdate() { + rm -rf rootdir/var/lib/apt + testfailure aptget update --allow-insecure-repositories + testsuccess grep "^E: Failed to fetch store:${1} Empty files can't be valid archives$" rootdir/tmp/testfailure.output +} +successupdate() { + rm -rf rootdir/var/lib/apt + testwarning aptget update --allow-insecure-repositories } -touch aptarchive/en.bz2 - -testaptgetupdate "Ign file: Release.gpg -Ign file:$(readlink -f aptarchive)/ Translation-en -Get:1 file: Release [] -Reading package lists..." "empty file en.bz2 over file" - -rm aptarchive/en.bz2 -echo -n "" | bzip2 > aptarchive/en.bz2 - -testaptgetupdate "Ign file: Release.gpg -Get:1 file: Release [] -Reading package lists..." "empty archive en.bz2 over file" - -rm aptarchive/en.bz2 - -# do the same again with http instead of file -changetowebserver - -touch aptarchive/en.bz2 +createemptyarchive() { + find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete + touch aptarchive/Packages + echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS + find aptarchive -name '*Release*' -delete + rm -f aptarchive/Packages +} -testaptgetupdate "Ign http://localhost Release.gpg -Get:1 http://localhost/ Translation-en -Get:2 http://localhost Release [] -Ign http://localhost/ Translation-en -Get:3 http://localhost Packages [] -Reading package lists..." "empty file en.bz2 over http" +createemptyfile() { + find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete + touch aptarchive/Packages aptarchive/${1}.$COMPRESS + find aptarchive -name '*Release*' -delete + rm -f aptarchive/Packages +} -rm aptarchive/en.bz2 -echo -n "" | bzip2 > aptarchive/en.bz2 +testoverfile() { + local APTARCHIVE="$(readlink -f ./aptarchive)" + forcecompressor "$1" -testaptgetupdate "Ign http://localhost Release.gpg -Get:1 http://localhost/ Translation-en [] -Get:2 http://localhost Release [] -Ign http://localhost Packages/DiffIndex -Get:3 http://localhost Packages [] -Reading package lists..." "empty archive en.bz2 over http" + msgmsg 'archive over file' "Packages.$COMPRESS" + createemptyarchive 'Packages' + successupdate + createemptyfile 'Packages' + failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})" +} -rm aptarchive/en.bz2 +testoverhttp() { + forcecompressor "$1" -rm aptarchive/Packages -touch aptarchive/Packages -buildaptarchivefromfiles - -testaptgetupdate "Ign http://localhost Release.gpg -Ign http://localhost/ Translation-en -Get:1 http://localhost Release [] -Ign http://localhost Packages/DiffIndex -Get:2 http://localhost Packages [] -Reading package lists..." "empty archive Packages over http" + msgmsg 'archive over http' "Packages.$COMPRESS" + createemptyarchive 'Packages' + successupdate + createemptyfile 'Packages' + failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})" +} -find aptarchive/ -name 'Packages*' -type f -delete -touch aptarchive/Packages.bz2 -aptftparchive release aptarchive/ > aptarchive/Release +forallsupportedcompressors testoverfile -#FIXME: we should response with a good error message instead -testaptgetupdate "Ign http://localhost Release.gpg -Ign http://localhost/ Translation-en -Get:1 http://localhost Release [] -Ign http://localhost Packages/DiffIndex -Get:2 http://localhost Packages -Err http://localhost Packages - Undetermined Error -W: Failed to fetch http://localhost:8080/Packages.bz2 Undetermined Error +# do the same again with http instead of file +changetowebserver -E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages over http" +forallsupportedcompressors testoverhttp