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

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