]> git.saurik.com Git - apt.git/blame - test/integration/test-acquire-same-file-multiple-times
fallback to well-known URI if by-hash fails
[apt.git] / test / integration / test-acquire-same-file-multiple-times
CommitLineData
08ea7806
DK
1#!/bin/sh
2set -e
3
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"
63c71412 15 testsuccess --nomsg apthelper download-file "file:///$APTARCHIVE/foo" ./downloaded/foo1 '' "file:///$APTARCHIVE/foo" ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1
08ea7806 16 cp rootdir/tmp/testsuccess.output download.log
63c71412 17 testsuccess cmp "$TESTFILE" ./downloaded/foo1
08ea7806 18 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
7c8206bf 19 testequal '1' grep -c '200%20URI%20Start' ./download.log
08ea7806
DK
20 testequal '1' grep -c '201%20URI%20Done' ./download.log
21 rm -f ./downloaded/foo1 ./downloaded/foo2
22}
23
24testrun() {
25 $1 'no partial'
63c71412 26 cp "$TESTFILE" ./downloaded/foo1
08ea7806 27 $1 'complete partial 1'
63c71412 28 cp "$TESTFILE" ./downloaded/foo2
08ea7806 29 $1 'complete partial 2'
63c71412
DK
30 cp "$TESTFILE" ./downloaded/foo1
31 cp "$TESTFILE" ./downloaded/foo2
08ea7806 32 $1 'complete partial 1+2'
63c71412 33 dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
08ea7806 34 $1 'partial partial 1'
63c71412 35 dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
08ea7806 36 $1 'partial partial 2'
63c71412
DK
37 dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
38 dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
08ea7806
DK
39 $1 'partial partial 1+2'
40}
41testrun 'filedown'
42
43changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo
44
45httpdown() {
46 msgtest 'Downloading the same URI to different files' 'twice over http'
9d2a8a73 47 testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
08ea7806 48 cp rootdir/tmp/testsuccess.output download.log
63c71412 49 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
08ea7806
DK
50 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
51 testequal '1' grep -c '200%20URI%20Start' ./download.log
52 testequal '1' grep -c '201%20URI%20Done' ./download.log
53 rm -f ./downloaded/foo1 ./downloaded/foo2
54}
55testrun 'httpdown'
56
57httpredirectdown() {
58 msgtest 'Redirect leads' 'first URI to the second URI'
9d2a8a73 59 testsuccess --nomsg apthelper download-file http://localhost:8080/foo2 ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
08ea7806 60 cp rootdir/tmp/testsuccess.output download.log
63c71412 61 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
08ea7806
DK
62 testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
63 testequal '1' grep -c '200%20URI%20Start' ./download.log
64 testequal '1' grep -c '103%20Redirect' ./download.log
65 testequal '1' grep -c '201%20URI%20Done' ./download.log
66 rm -f ./downloaded/foo1 ./downloaded/foo2
67}
68testrun 'httpredirectdown'
69
70httpsamedown() {
71 msgtest 'Downloading two files via the same URI to' 'the same file'
72 testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo1 '' -o Debug::pkgAcquire::Worker=1
73 cp rootdir/tmp/testsuccess.output download.log
63c71412 74 testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
08ea7806
DK
75 testequal '1' grep -c '200%20URI%20Start' ./download.log
76 testequal '1' grep -c '201%20URI%20Done' ./download.log
77 rm -f ./downloaded/foo1
78}
79testrun 'httpsamedown'