test-acquire-same-file-multiple-times 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. TESTFILE="$TESTDIR/framework"
  8. cp "$TESTFILE" aptarchive/foo
  9. APTARCHIVE="$(readlink -f ./aptarchive)"
  10. filedown() {
  11. msgtest 'Downloading the same URI twice over file' "$1"
  12. testsuccess --nomsg apthelper download-file "file:///$APTARCHIVE/foo" ./downloaded/foo1 '' "file:///$APTARCHIVE/foo" ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1
  13. cp rootdir/tmp/testsuccess.output download.log
  14. testsuccess cmp "$TESTFILE" ./downloaded/foo1
  15. testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
  16. testequal '1' grep -c '200%20URI%20Start' ./download.log
  17. testequal '1' grep -c '201%20URI%20Done' ./download.log
  18. rm -f ./downloaded/foo1 ./downloaded/foo2
  19. }
  20. testrun() {
  21. $1 'no partial'
  22. cp "$TESTFILE" ./downloaded/foo1
  23. $1 'complete partial 1'
  24. cp "$TESTFILE" ./downloaded/foo2
  25. $1 'complete partial 2'
  26. cp "$TESTFILE" ./downloaded/foo1
  27. cp "$TESTFILE" ./downloaded/foo2
  28. $1 'complete partial 1+2'
  29. dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
  30. $1 'partial partial 1'
  31. dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
  32. $1 'partial partial 2'
  33. dd if="$TESTFILE" of=./downloaded/foo1 bs=500 count=1 2>/dev/null
  34. dd if="$TESTFILE" of=./downloaded/foo2 bs=500 count=1 2>/dev/null
  35. $1 'partial partial 1+2'
  36. }
  37. testrun 'filedown'
  38. changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo
  39. httpdown() {
  40. msgtest 'Downloading the same URI to different files' 'twice over http'
  41. 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
  42. cp rootdir/tmp/testsuccess.output download.log
  43. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  44. testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
  45. testequal '1' grep -c '200%20URI%20Start' ./download.log
  46. testequal '1' grep -c '201%20URI%20Done' ./download.log
  47. rm -f ./downloaded/foo1 ./downloaded/foo2
  48. }
  49. testrun 'httpdown'
  50. httpredirectdown() {
  51. msgtest 'Redirect leads' 'first URI to the second URI'
  52. 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
  53. cp rootdir/tmp/testsuccess.output download.log
  54. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  55. testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
  56. testequal '1' grep -c '200%20URI%20Start' ./download.log
  57. testequal '1' grep -c '103%20Redirect' ./download.log
  58. testequal '1' grep -c '201%20URI%20Done' ./download.log
  59. rm -f ./downloaded/foo1 ./downloaded/foo2
  60. }
  61. testrun 'httpredirectdown'
  62. httpsamedown() {
  63. msgtest 'Downloading two files via the same URI to' 'the same file'
  64. testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo1 '' -o Debug::pkgAcquire::Worker=1
  65. cp rootdir/tmp/testsuccess.output download.log
  66. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  67. testequal '1' grep -c '200%20URI%20Start' ./download.log
  68. testequal '1' grep -c '201%20URI%20Done' ./download.log
  69. rm -f ./downloaded/foo1
  70. }
  71. testrun 'httpsamedown'