]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-expected-size
tests: allow to disable generation of InRelease/Release.gpg file
[apt.git] / test / integration / test-apt-update-expected-size
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6
7 setupenvironment
8 configarchitecture 'i386'
9 configcompression '.' 'gz'
10
11 insertpackage 'unstable' 'apt' 'i386' '1.0'
12
13 setupaptarchive --no-update
14 cp -a aptarchive/dists aptarchive/dists.good
15
16 test_inreleasetoobig() {
17 # make InRelease really big to trigger fallback
18 dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
19 touch -d '+1hour' aptarchive/dists/unstable/InRelease
20 testsuccess aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
21 msgtest 'Check that the max write warning is triggered'
22 cp rootdir/tmp/testsuccess.output update.output
23 testsuccess --nomsg grep -q 'Writing more data than expected' update.output
24 rm -f update.output
25 # ensure the failed InRelease file got renamed
26 testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
27 }
28
29 test_packagestoobig() {
30 insertpackage 'unstable' 'foo' 'i386' '1.0'
31 buildaptarchivefromfiles '+1 hour'
32 signreleasefiles
33 # append junk at the end of the Packages.gz/Packages
34 SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
35 find aptarchive/dists -name 'Packages*' | while read pkg; do
36 echo "1234567890" >> "$pkg"
37 touch -d '+1hour' "$pkg"
38 done
39 NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
40 testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz Writing more data than expected ($NEW_SIZE > $SIZE)
41 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
42 }
43
44 methodtest() {
45 # less complicated test setup this way
46 webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
47 webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
48
49 msgmsg 'Test with' "$1" 'and clean start'
50 rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
51 # normal update works fine
52 testsuccess aptget update
53 mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
54
55 # starting fresh works
56 test_inreleasetoobig "$1"
57 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
58 cp -a aptarchive/dists.good aptarchive/dists
59 test_packagestoobig "$1"
60 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
61 cp -a aptarchive/dists.good aptarchive/dists
62
63 msgmsg 'Test with' "$1" 'and existing old data'
64 cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
65 test_inreleasetoobig "$1"
66 rm -rf aptarchive/dists rootdir/var/lib/apt/lists
67 cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
68 cp -a aptarchive/dists.good aptarchive/dists
69 test_packagestoobig "$1"
70 rm -rf aptarchive/dists
71 cp -a aptarchive/dists.good aptarchive/dists
72 }
73
74 changetowebserver
75 methodtest "http://localhost:${APTHTTPPORT}"
76
77 changetohttpswebserver
78 methodtest "https://localhost:${APTHTTPSPORT}"