]>
Commit | Line | Data |
---|---|---|
08ea7806 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
63c71412 | 5 | . "$TESTDIR/framework" |
08ea7806 DK |
6 | setupenvironment |
7 | configarchitecture 'amd64' | |
8 | ||
9 | TESTFILE="$TESTDIR/framework" | |
63c71412 | 10 | cp "$TESTFILE" aptarchive/foo |
08ea7806 DK |
11 | APTARCHIVE="$(readlink -f ./aptarchive)" |
12 | ||
13 | filedown() { | |
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 | ||
24 | testrun() { | |
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 | } | |
41 | testrun 'filedown' | |
42 | ||
43 | changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo | |
44 | ||
45 | httpdown() { | |
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 | } | |
55 | testrun 'httpdown' | |
56 | ||
57 | httpredirectdown() { | |
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 | } | |
68 | testrun 'httpredirectdown' | |
69 | ||
70 | httpsamedown() { | |
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 | } | |
79 | testrun 'httpsamedown' |