4 TESTDIR
=$(readlink -f $(dirname $0))
7 configarchitecture
'amd64'
12 dd if="$1" bs
=1 count
="$2" of
="$3" 2>/dev
/null
13 touch -d "$(stat --format '%y' "${TESTFILE}")" "$3"
16 DOWNLOADLOG
='rootdir/tmp/testdownloadfile.log'
20 msgtest
"Testing download of file $2 with" "$1"
21 if ! downloadfile
"$2" "$3" > "$DOWNLOADLOG"; then
22 cat >&2 "$DOWNLOADLOG"
27 cat "$DOWNLOADLOG" | while read field
hash; do
30 'MD5Sum-Hash:') EXPECTED
="$(md5sum "$TESTFILE" | cut -d' ' -f 1)";;
31 'SHA1-Hash:') EXPECTED
="$(sha1sum "$TESTFILE" | cut -d' ' -f 1)";;
32 'SHA256-Hash:') EXPECTED
="$(sha256sum "$TESTFILE" | cut -d' ' -f 1)";;
33 'SHA512-Hash:') EXPECTED
="$(sha512sum "$TESTFILE" | cut -d' ' -f 1)";;
36 if [ "$4" = '=' ]; then
37 msgtest
'Test downloaded file for correct' "$field"
39 msgtest
'Test downloaded file does not match in' "$field"
41 if [ "$EXPECTED" "$4" "$hash" ]; then
44 cat >&2 "$DOWNLOADLOG"
45 msgfail
"expected: $EXPECTED ; got: $hash"
50 TESTFILE
='aptarchive/testfile'
51 cp -a ${TESTDIR}/framework
$TESTFILE
54 webserverconfig
'aptwebserver::support::range' 'true'
56 copysource
$TESTFILE 0 .
/testfile
57 testdownloadfile
'no data' "${1}/testfile" './testfile' '='
58 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
60 copysource
$TESTFILE 20 .
/testfile
61 testdownloadfile
'valid partial data' "${1}/testfile" './testfile' '='
62 testwebserverlaststatuscode
'206' "$DOWNLOADLOG"
64 copysource
/dev
/zero
20 .
/testfile
65 testdownloadfile
'invalid partial data' "${1}/testfile" './testfile' '!='
66 testwebserverlaststatuscode
'206' "$DOWNLOADLOG"
68 copysource
$TESTFILE 1M .
/testfile
69 testdownloadfile
'completely downloaded file' "${1}/testfile" './testfile' '='
70 testwebserverlaststatuscode
'416' "$DOWNLOADLOG"
72 copysource
/dev
/zero
1M .
/testfile
73 testdownloadfile
'too-big partial file' "${1}/testfile" './testfile' '='
74 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
76 copysource
/dev
/zero
20 .
/testfile
78 testdownloadfile
'old data' "${1}/testfile" './testfile' '='
79 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
81 webserverconfig
'aptwebserver::support::range' 'false'
83 copysource
$TESTFILE 20 .
/testfile
84 testdownloadfile
'no server support' "${1}/testfile" './testfile' '='
85 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
88 testrun
'http://localhost:8080'
90 changetohttpswebserver
92 testrun
'https://localhost:4433'