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