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.
 
 
 
 
 
 

78 lines
2.9 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture "i386"
  7. insertpackage 'unstable' 'apt' 'i386' '1.0'
  8. setupaptarchive --no-update
  9. cp -a aptarchive/dists aptarchive/dists.good
  10. test_inreleasetoobig() {
  11. # make InRelease really big to trigger fallback
  12. dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
  13. touch -d '+1hour' aptarchive/dists/unstable/InRelease
  14. testsuccess aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
  15. msgtest 'Check that the max write warning is triggered'
  16. cp rootdir/tmp/testsuccess.output update.output
  17. testsuccess --nomsg grep -q 'Writing more data than expected' update.output
  18. rm -f update.output
  19. # ensure the failed InRelease file got renamed
  20. testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
  21. }
  22. test_packagestoobig() {
  23. insertpackage 'unstable' 'foo' 'i386' '1.0'
  24. buildaptarchivefromfiles '+1 hour'
  25. signreleasefiles
  26. # append junk at the end of the Packages.gz/Packages
  27. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
  28. find aptarchive/dists -name 'Packages*' | while read pkg; do
  29. echo "1234567890" >> "$pkg"
  30. touch -d '+1hour' "$pkg"
  31. done
  32. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
  33. testfailuremsg "W: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages Writing more data than expected ($NEW_SIZE > $SIZE)
  34. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
  35. }
  36. methodtest() {
  37. # less complicated test setup this way
  38. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  39. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  40. msgmsg 'Test with' "$1" 'and clean start'
  41. rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  42. # normal update works fine
  43. testsuccess aptget update
  44. mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  45. # starting fresh works
  46. test_inreleasetoobig "$1"
  47. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  48. cp -a aptarchive/dists.good aptarchive/dists
  49. test_packagestoobig "$1"
  50. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  51. cp -a aptarchive/dists.good aptarchive/dists
  52. msgmsg 'Test with' "$1" 'and existing old data'
  53. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  54. test_inreleasetoobig "$1"
  55. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  56. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  57. cp -a aptarchive/dists.good aptarchive/dists
  58. test_packagestoobig "$1"
  59. rm -rf aptarchive/dists
  60. cp -a aptarchive/dists.good aptarchive/dists
  61. }
  62. changetowebserver
  63. methodtest "http://localhost:${APTHTTPPORT}"
  64. changetohttpswebserver
  65. methodtest "https://localhost:${APTHTTPSPORT}"