]> git.saurik.com Git - apt.git/blame - test/integration/test-acquire-same-file-multiple-times
fix testcase expecting incorrect remove log from dpkg
[apt.git] / test / integration / test-acquire-same-file-multiple-times
CommitLineData
08ea7806
DK
1#!/bin/sh
2set -e
3
3abb6a6a 4TESTDIR="$(readlink -f "$(dirname "$0")")"
63c71412 5. "$TESTDIR/framework"
08ea7806
DK
6setupenvironment
7configarchitecture 'amd64'
8
9TESTFILE="$TESTDIR/framework"
63c71412 10cp "$TESTFILE" aptarchive/foo
08ea7806
DK
11APTARCHIVE="$(readlink -f ./aptarchive)"
12
13filedown() {
14 msgtest 'Downloading the same URI twice over file' "$1"
6c0765c0
DK
15 testsuccess --nomsg apthelper download-file "file:///$APTARCHIVE/foo" './downloaded/foo1' '' \
16 "file:///$APTARCHIVE/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1
08ea7806 17 cp rootdir/tmp/testsuccess.output download.log
63c71412 18 testsuccess cmp "$TESTFILE" ./downloaded/foo1
08ea7806 19 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
7c8206bf 20 testequal '1' grep -c '200%20URI%20Start' ./download.log
08ea7806
DK
21 testequal '1' grep -c '201%20URI%20Done' ./download.log
22 rm -f ./downloaded/foo1 ./downloaded/foo2
23}
24
25testrun() {
26 $1 'no partial'
63c71412 27 cp "$TESTFILE" ./downloaded/foo1
08ea7806 28 $1 'complete partial 1'
63c71412 29 cp "$TESTFILE" ./downloaded/foo2
08ea7806 30 $1 'complete partial 2'
63c71412
DK
31 cp "$TESTFILE" ./downloaded/foo1
32 cp "$TESTFILE" ./downloaded/foo2
08ea7806 33 $1 'complete partial 1+2'
63c71412 34 dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
08ea7806 35 $1 'partial partial 1'
63c71412 36 dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
08ea7806 37 $1 'partial partial 2'
63c71412
DK
38 dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
39 dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
08ea7806
DK
40 $1 'partial partial 1+2'
41}
42testrun 'filedown'
43
44changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo
45
46httpdown() {
47 msgtest 'Downloading the same URI to different files' 'twice over http'
6c0765c0
DK
48 testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
49 "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
08ea7806 50 cp rootdir/tmp/testsuccess.output download.log
63c71412 51 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
08ea7806
DK
52 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
53 testequal '1' grep -c '200%20URI%20Start' ./download.log
54 testequal '1' grep -c '201%20URI%20Done' ./download.log
55 rm -f ./downloaded/foo1 ./downloaded/foo2
56}
57testrun 'httpdown'
58
59httpredirectdown() {
60 msgtest 'Redirect leads' 'first URI to the second URI'
c030cc93 61 for i in 1 2 3 4 5 6 7 8 9 10; do
cf2d4e7c 62 rm -f ./downloaded/foo1 ./downloaded/foo2
c030cc93
JAK
63 testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo2" "./downloaded/foo1" '' \
64 "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
65 cp rootdir/tmp/testsuccess.output download.log
66 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
67 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
68
69 if grep -q '103%20Redirect' ./download.log; then
70 break
71 fi
72 done
08ea7806
DK
73 testequal '1' grep -c '200%20URI%20Start' ./download.log
74 testequal '1' grep -c '103%20Redirect' ./download.log
75 testequal '1' grep -c '201%20URI%20Done' ./download.log
76 rm -f ./downloaded/foo1 ./downloaded/foo2
77}
78testrun 'httpredirectdown'
79
80httpsamedown() {
81 msgtest 'Downloading two files via the same URI to' 'the same file'
6c0765c0
DK
82 testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
83 "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo1' '' -o Debug::pkgAcquire::Worker=1
08ea7806 84 cp rootdir/tmp/testsuccess.output download.log
63c71412 85 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
08ea7806
DK
86 testequal '1' grep -c '200%20URI%20Start' ./download.log
87 testequal '1' grep -c '201%20URI%20Done' ./download.log
88 rm -f ./downloaded/foo1
89}
90testrun 'httpsamedown'