test-apt-ftparchive-cachedb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. set -e
  3. ensure_correct_packages_file() {
  4. testequal "Package: foo
  5. Architecture: i386
  6. Version: 1
  7. Priority: optional
  8. Section: others
  9. Maintainer: Joe Sixpack <joe@example.org>
  10. $(dpkg-deb -I ./aptarchive/pool/main/foo_1_i386.deb | grep 'Installed-Size:' | sed 's#^ ##')
  11. Filename: pool/main/foo_1_i386.deb" head -n8 ./aptarchive/dists/test/main/binary-i386/Packages
  12. }
  13. ensure_correct_contents_file() {
  14. testfileequal ./aptarchive/dists/test/Contents-i386 "usr/bin/foo-i386 others/foo
  15. usr/share/doc/foo/FEATURES others/foo
  16. usr/share/doc/foo/changelog others/foo
  17. usr/share/doc/foo/copyright others/foo"
  18. }
  19. #
  20. # main()
  21. #
  22. TESTDIR=$(readlink -f $(dirname $0))
  23. . $TESTDIR/framework
  24. setupenvironment
  25. configarchitecture 'i386'
  26. mkdir -p aptarchive/dists/test/main/i18n/
  27. mkdir -p aptarchive/dists/test/main/source/
  28. mkdir -p aptarchive/dists/test/main/binary-i386
  29. mkdir -p aptarchive/pool/main
  30. mkdir aptarchive-overrides
  31. mkdir aptarchive-cache
  32. cat > ftparchive.conf <<"EOF"
  33. Dir {
  34. ArchiveDir "./aptarchive";
  35. OverrideDir "./aptarchive-overrides";
  36. CacheDir "./aptarchive-cache";
  37. };
  38. Default {
  39. Packages::Compress ". gzip bzip2";
  40. Contents::Compress ". gzip bzip2";
  41. LongDescription "false";
  42. };
  43. TreeDefault {
  44. BinCacheDB "packages-$(SECTION)-$(ARCH).db";
  45. Directory "pool/$(SECTION)";
  46. SrcDirectory "pool/$(SECTION)";
  47. Packages "$(DIST)/$(SECTION)/binary-$(ARCH)/Packages";
  48. Contents "$(DIST)/Contents-$(ARCH)";
  49. };
  50. Tree "dists/test" {
  51. Sections "main";
  52. Architectures "i386";
  53. };
  54. EOF
  55. # build one pacakge
  56. buildsimplenativepackage 'foo' 'i386' '1' 'test'
  57. mv incoming/* aptarchive/pool/main/
  58. # generate (empty cachedb)
  59. testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
  60. cp rootdir/tmp/testsuccess.output stats-out.txt
  61. ensure_correct_packages_file
  62. ensure_correct_contents_file
  63. testsuccess grep Misses stats-out.txt
  64. testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 2
  65. dists/test/Contents-i386: New 402 B Misses in Cache: 0'
  66. # generate again
  67. testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
  68. cp rootdir/tmp/testsuccess.output stats-out.txt
  69. ensure_correct_packages_file
  70. ensure_correct_contents_file
  71. testsuccess grep Misses stats-out.txt
  72. testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 0
  73. dists/test/Contents-i386: Misses in Cache: 0'
  74. # and again (with removing the Packages file)
  75. rm -f ./aptarchive/dists/test/main/binary-i386/*
  76. rm -f ./aptarchive/dists/test/Contents-i386
  77. testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
  78. cp rootdir/tmp/testsuccess.output stats-out.txt
  79. ensure_correct_packages_file
  80. ensure_correct_contents_file
  81. testsuccess grep Misses stats-out.txt
  82. testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 0
  83. dists/test/Contents-i386: New 402 B Misses in Cache: 0'
  84. # and clean
  85. rm -rf aptarchive/pool/main/*
  86. testsuccessequal "packages-main-i386.db" aptftparchive clean ftparchive.conf -q=0
  87. testsuccess aptftparchive clean ftparchive.conf -q=0 -o Debug::APT::FTPArchive::Clean=1
  88. cp rootdir/tmp/testsuccess.output clean-out.txt
  89. testsuccessequal "0 Number of unique keys in the tree" grep unique clean-out.txt
  90. testsuccessequal "packages-main-i386.db" grep packages-main-i386.db clean-out.txt