You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 lines
3.3 KiB

  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' '' \
  13. "file:///$APTARCHIVE/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1
  14. cp rootdir/tmp/testsuccess.output 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:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
  43. "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
  44. cp rootdir/tmp/testsuccess.output download.log
  45. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  46. testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
  47. testequal '1' grep -c '200%20URI%20Start' ./download.log
  48. testequal '1' grep -c '201%20URI%20Done' ./download.log
  49. rm -f ./downloaded/foo1 ./downloaded/foo2
  50. }
  51. testrun 'httpdown'
  52. httpredirectdown() {
  53. msgtest 'Redirect leads' 'first URI to the second URI'
  54. testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo2" "./downloaded/foo1" '' \
  55. "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
  56. cp rootdir/tmp/testsuccess.output download.log
  57. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  58. testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
  59. testequal '1' grep -c '200%20URI%20Start' ./download.log
  60. testequal '1' grep -c '103%20Redirect' ./download.log
  61. testequal '1' grep -c '201%20URI%20Done' ./download.log
  62. rm -f ./downloaded/foo1 ./downloaded/foo2
  63. }
  64. testrun 'httpredirectdown'
  65. httpsamedown() {
  66. msgtest 'Downloading two files via the same URI to' 'the same file'
  67. testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
  68. "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo1' '' -o Debug::pkgAcquire::Worker=1
  69. cp rootdir/tmp/testsuccess.output download.log
  70. testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
  71. testequal '1' grep -c '200%20URI%20Start' ./download.log
  72. testequal '1' grep -c '201%20URI%20Done' ./download.log
  73. rm -f ./downloaded/foo1
  74. }
  75. testrun 'httpsamedown'