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.
 
 
 
 
 
 

96 lines
3.0 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#Get:[0-9]\+ #Get: #' -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. if [ "en" = "$1" ]; then
  27. echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
  28. fi
  29. touch aptarchive/Packages
  30. echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
  31. generatereleasefiles
  32. signreleasefiles
  33. rm -f aptarchive/Packages
  34. }
  35. createemptyfile() {
  36. find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
  37. if [ "en" = "$1" ]; then
  38. echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
  39. fi
  40. touch aptarchive/Packages aptarchive/${1}.$COMPRESS
  41. generatereleasefiles
  42. signreleasefiles
  43. rm -f aptarchive/Packages
  44. }
  45. testoverfile() {
  46. forcecompressor "$1"
  47. createemptyfile 'en'
  48. testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
  49. createemptyarchive 'en'
  50. testaptgetupdate 'Reading package lists...' "empty archive en.$COMPRESS over file"
  51. createemptyarchive 'Packages'
  52. # FIXME: Why omits the file transport the Packages Get line?
  53. #Get:3 file: Packages []
  54. testaptgetupdate 'Reading package lists...' "empty archive Packages.$COMPRESS over file"
  55. createemptyfile 'Packages'
  56. testaptgetupdate "Err file: Packages
  57. Empty files can't be valid archives
  58. W: Failed to fetch ${COMPRESSOR}:$(readlink -f aptarchive/Packages.$COMPRESS) Empty files can't be valid archives
  59. E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
  60. }
  61. testoverhttp() {
  62. forcecompressor "$1"
  63. createemptyarchive 'Packages'
  64. testaptgetupdate "Get: http://localhost:8080 Packages []
  65. Reading package lists..." "empty archive Packages.$COMPRESS over http"
  66. createemptyfile 'Packages'
  67. #FIXME: we should response with a good error message instead
  68. testaptgetupdate "Get: http://localhost:8080 Packages
  69. Err http://localhost:8080 Packages
  70. Empty files can't be valid archives
  71. W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
  72. E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
  73. }
  74. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
  75. # do the same again with http instead of file
  76. changetowebserver
  77. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done