]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-595691-empty-and-broken-archive-files
deal better with acquiring the same URI multiple times
[apt.git] / test / integration / test-bug-595691-empty-and-broken-archive-files
CommitLineData
6874a1a8
DK
1#!/bin/sh
2set -e
3
9962ae93 4TESTDIR=$(readlink -f $(dirname $0))
6874a1a8
DK
5. $TESTDIR/framework
6setupenvironment
7configarchitecture "i386"
8
9buildaptarchive
db4b5f77 10touch aptarchive/Packages
6874a1a8
DK
11setupflataptarchive
12
13testaptgetupdate() {
8de79b68 14 rm -rf rootdir/var/lib/apt
448c38bd 15 aptget update >testaptgetupdate.diff 2>&1 || true
4dbfe436 16 sed -i -e '/Ign /,+1d' -e '/Release/ d' -e 's#Get:[0-9]\+ #Get: #' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
6874a1a8
DK
17 GIVEN="$1"
18 shift
19 msgtest "Test for correctness of" "apt-get update with $*"
20 if [ -z "$GIVEN" ]; then
21 echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
22 else
23 echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
24 fi
25 rm testaptgetupdate.diff
26}
27
4260fd39
DK
28createemptyarchive() {
29 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
30 if [ "en" = "$1" ]; then
8bcbc694 31 echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
4260fd39
DK
32 fi
33 touch aptarchive/Packages
8bcbc694 34 echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
ab53c018 35 generatereleasefiles
4260fd39
DK
36 signreleasefiles
37 rm -f aptarchive/Packages
38}
6874a1a8 39
4260fd39
DK
40createemptyfile() {
41 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
42 if [ "en" = "$1" ]; then
8bcbc694 43 echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
4260fd39
DK
44 fi
45 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
ab53c018 46 generatereleasefiles
4260fd39
DK
47 signreleasefiles
48 rm -f aptarchive/Packages
49}
6874a1a8 50
4260fd39 51testoverfile() {
1da3b7b8 52 local APTARCHIVE="$(readlink -f ./aptarchive)"
5f982b9d 53 forcecompressor "$1"
6874a1a8 54
4260fd39 55 createemptyfile 'en'
55971004 56 testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
4260fd39
DK
57
58 createemptyarchive 'en'
55971004 59 testaptgetupdate 'Reading package lists...' "empty archive en.$COMPRESS over file"
4260fd39
DK
60
61 createemptyarchive 'Packages'
62 # FIXME: Why omits the file transport the Packages Get line?
63 #Get:3 file: Packages []
55971004 64 testaptgetupdate 'Reading package lists...' "empty archive Packages.$COMPRESS over file"
4260fd39
DK
65
66 createemptyfile 'Packages'
1da3b7b8 67 testaptgetupdate "Err file:$APTARCHIVE Packages
5d885723 68 Empty files can't be valid archives
1da3b7b8 69W: Failed to fetch ${COMPRESSOR}:${APTARCHIVE}/Packages.$COMPRESS Empty files can't be valid archives
6874a1a8 70
196c511c 71E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
4260fd39 72}
6874a1a8 73
4260fd39 74testoverhttp() {
5f982b9d 75 forcecompressor "$1"
6874a1a8 76
4260fd39 77 createemptyarchive 'Packages'
5b63d2a9 78 testaptgetupdate "Get: http://localhost:8080 Packages []
4260fd39 79Reading package lists..." "empty archive Packages.$COMPRESS over http"
6874a1a8 80
4260fd39
DK
81 createemptyfile 'Packages'
82 #FIXME: we should response with a good error message instead
5b63d2a9
MV
83 testaptgetupdate "Get: http://localhost:8080 Packages
84Err http://localhost:8080 Packages
5d885723 85 Empty files can't be valid archives
b0f4b486 86W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
4260fd39 87
196c511c 88E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
4260fd39
DK
89}
90
79d5bab6 91for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
4260fd39
DK
92
93# do the same again with http instead of file
94changetowebserver
6874a1a8 95
79d5bab6 96for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done