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