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.
 
 
 
 
 
 

85 lines
2.7 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildaptarchive
  8. touch aptarchive/Packages
  9. setupflataptarchive
  10. testaptgetupdate() {
  11. rm -rf rootdir/var/lib/apt
  12. aptget update >testaptgetupdate.diff 2>&1 || true
  13. sed -i -e '/Ign /,+1d' -e '/Release/ d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
  14. GIVEN="$1"
  15. shift
  16. msgtest "Test for correctness of" "apt-get update with $*"
  17. if [ -z "$GIVEN" ]; then
  18. echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
  19. else
  20. echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
  21. fi
  22. rm testaptgetupdate.diff
  23. }
  24. createemptyarchive() {
  25. find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
  26. touch aptarchive/Packages
  27. echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
  28. generatereleasefiles
  29. signreleasefiles
  30. rm -f aptarchive/Packages
  31. }
  32. createemptyfile() {
  33. find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
  34. touch aptarchive/Packages aptarchive/${1}.$COMPRESS
  35. generatereleasefiles
  36. signreleasefiles
  37. rm -f aptarchive/Packages
  38. }
  39. testoverfile() {
  40. local APTARCHIVE="$(readlink -f ./aptarchive)"
  41. forcecompressor "$1"
  42. createemptyarchive 'Packages'
  43. testaptgetupdate "Get:2 file:$APTARCHIVE Packages []
  44. Reading package lists..." "empty archive Packages.$COMPRESS over file"
  45. createemptyfile 'Packages'
  46. testaptgetupdate "Get:2 file:$APTARCHIVE Packages
  47. Err:2 file:$APTARCHIVE Packages
  48. Empty files can't be valid archives
  49. Reading package lists...
  50. W: Failed to fetch ${COMPRESSOR}:${APTARCHIVE}/Packages.$COMPRESS Empty files can't be valid archives
  51. E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
  52. }
  53. testoverhttp() {
  54. forcecompressor "$1"
  55. createemptyarchive 'Packages'
  56. testaptgetupdate "Get:2 http://localhost:${APTHTTPPORT} Packages []
  57. Reading package lists..." "empty archive Packages.$COMPRESS over http"
  58. createemptyfile 'Packages'
  59. #FIXME: we should response with a good error message instead
  60. testaptgetupdate "Get:2 http://localhost:${APTHTTPPORT} Packages
  61. Err:2 http://localhost:${APTHTTPPORT} Packages
  62. Empty files can't be valid archives
  63. Reading package lists...
  64. W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS}) Empty files can't be valid archives
  65. E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
  66. }
  67. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
  68. # do the same again with http instead of file
  69. changetowebserver
  70. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done