]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-595691-empty-and-broken-archive-files
drop extra newline in 'Failed to fetch' and 'GPG error' message
[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
1eb1836f 16 sed -i -e '/Ign /,+1d' -e '/Release/ d' -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
4260fd39 30 touch aptarchive/Packages
8bcbc694 31 echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
ab53c018 32 generatereleasefiles
4260fd39
DK
33 signreleasefiles
34 rm -f aptarchive/Packages
35}
6874a1a8 36
4260fd39
DK
37createemptyfile() {
38 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
4260fd39 39 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
ab53c018 40 generatereleasefiles
4260fd39
DK
41 signreleasefiles
42 rm -f aptarchive/Packages
43}
6874a1a8 44
4260fd39 45testoverfile() {
1da3b7b8 46 local APTARCHIVE="$(readlink -f ./aptarchive)"
5f982b9d 47 forcecompressor "$1"
6874a1a8 48
4260fd39 49 createemptyarchive 'Packages'
1eb1836f 50 testaptgetupdate "Get:2 file:$APTARCHIVE Packages []
ff86d7df 51Reading package lists..." "empty archive Packages.$COMPRESS over file"
4260fd39
DK
52
53 createemptyfile 'Packages'
1eb1836f
DK
54 testaptgetupdate "Get:2 file:$APTARCHIVE Packages
55Err:2 file:$APTARCHIVE Packages
5d885723 56 Empty files can't be valid archives
1da3b7b8 57W: Failed to fetch ${COMPRESSOR}:${APTARCHIVE}/Packages.$COMPRESS Empty files can't be valid archives
196c511c 58E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
4260fd39 59}
6874a1a8 60
4260fd39 61testoverhttp() {
5f982b9d 62 forcecompressor "$1"
6874a1a8 63
4260fd39 64 createemptyarchive 'Packages'
1eb1836f 65 testaptgetupdate "Get:2 http://localhost:8080 Packages []
4260fd39 66Reading package lists..." "empty archive Packages.$COMPRESS over http"
6874a1a8 67
4260fd39
DK
68 createemptyfile 'Packages'
69 #FIXME: we should response with a good error message instead
1eb1836f
DK
70 testaptgetupdate "Get:2 http://localhost:8080 Packages
71Err:2 http://localhost:8080 Packages
5d885723 72 Empty files can't be valid archives
b0f4b486 73W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
196c511c 74E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
4260fd39
DK
75}
76
79d5bab6 77for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
4260fd39
DK
78
79# do the same again with http instead of file
80changetowebserver
6874a1a8 81
79d5bab6 82for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done