diff options
author | Michael Vogt <mvo@debian.org> | 2014-03-14 09:02:44 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-03-14 09:02:44 +0100 |
commit | 83b880c6505a20247239d897b7387bba37942993 (patch) | |
tree | 11a23275548175e301f6fefda20a6a8bb6fe6de8 /test/integration/test-partial-file-support | |
parent | f98d9bd2adf4f24a72d973f5752b47987843984c (diff) | |
parent | 40f8a8ba8c2e7ff9ce80781250c863c07ac130dd (diff) |
fix test/integration/test-apt-helper
Diffstat (limited to 'test/integration/test-partial-file-support')
-rwxr-xr-x | test/integration/test-partial-file-support | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/test/integration/test-partial-file-support b/test/integration/test-partial-file-support index 382789e68..5ab326def 100755 --- a/test/integration/test-partial-file-support +++ b/test/integration/test-partial-file-support @@ -13,17 +13,18 @@ copysource() { touch -d "$(stat --format '%y' "${TESTFILE}")" "$3" } +DOWNLOADLOG='rootdir/tmp/testdownloadfile.log' + testdownloadfile() { - local DOWNLOG='download-testfile.log' - rm -f "$DOWNLOG" + rm -f "$DOWNLOADLOG" msgtest "Testing download of file $2 with" "$1" - if ! downloadfile "$2" "$3" > "$DOWNLOG"; then - cat >&2 "$DOWNLOG" + if ! downloadfile "$2" "$3" > "$DOWNLOADLOG"; then + cat >&2 "$DOWNLOADLOG" msgfail else msgpass fi - cat "$DOWNLOG" | while read field hash; do + cat "$DOWNLOADLOG" | while read field hash; do local EXPECTED case "$field" in 'MD5Sum-Hash:') EXPECTED="$(md5sum "$TESTFILE" | cut -d' ' -f 1)";; @@ -40,28 +41,12 @@ testdownloadfile() { if [ "$EXPECTED" "$4" "$hash" ]; then msgpass else - cat >&2 "$DOWNLOG" + cat >&2 "$DOWNLOADLOG" msgfail "expected: $EXPECTED ; got: $hash" fi done } -testwebserverlaststatuscode() { - local DOWNLOG='download-testfile.log' - rm -f "$DOWNLOG" - local STATUS="$(mktemp)" - addtrap "rm $STATUS;" - msgtest 'Test last status code from the webserver was' "$1" - downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" - if [ "$(cat "$STATUS")" = "$1" ]; then - msgpass - else - cat >&2 "$DOWNLOG" - msgfail "Status was $(cat "$STATUS")" - fi -} - - TESTFILE='aptarchive/testfile' cp -a ${TESTDIR}/framework $TESTFILE @@ -70,34 +55,34 @@ testrun() { copysource $TESTFILE 0 ./testfile testdownloadfile 'no data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" copysource $TESTFILE 20 ./testfile testdownloadfile 'valid partial data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '206' + testwebserverlaststatuscode '206' "$DOWNLOADLOG" copysource /dev/zero 20 ./testfile testdownloadfile 'invalid partial data' "${1}/testfile" './testfile' '!=' - testwebserverlaststatuscode '206' + testwebserverlaststatuscode '206' "$DOWNLOADLOG" copysource $TESTFILE 1M ./testfile testdownloadfile 'completely downloaded file' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '416' + testwebserverlaststatuscode '416' "$DOWNLOADLOG" copysource /dev/zero 1M ./testfile testdownloadfile 'too-big partial file' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" copysource /dev/zero 20 ./testfile touch ./testfile testdownloadfile 'old data' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" webserverconfig 'aptwebserver::support::range' 'false' copysource $TESTFILE 20 ./testfile testdownloadfile 'no server support' "${1}/testfile" './testfile' '=' - testwebserverlaststatuscode '200' + testwebserverlaststatuscode '200' "$DOWNLOADLOG" } testrun 'http://localhost:8080' |