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.
 
 
 
 
 
 

102 lines
2.8 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. configdpkgnoopchroot
  8. setupsimplenativepackage "fdleaks" 'all' '1.0' 'unstable'
  9. BUILDDIR="incoming/fdleaks-1.0"
  10. for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
  11. echo '#!/bin/sh
  12. ls -l /proc/self/fd/' > ${BUILDDIR}/debian/$script
  13. done
  14. buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
  15. rm -rf "$BUILDDIR"
  16. PKGNAME='fdleaks:all'
  17. if ! dpkg-checkbuilddeps -d 'dpkg (>= 1.16.2)' /dev/null >/dev/null 2>&1; then
  18. PKGNAME='fdleaks'
  19. fi
  20. setupaptarchive
  21. rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
  22. testsuccess aptget install -y fdleaks -qq < /dev/null
  23. checkfdleak() {
  24. msgtest 'Check if fds were not' 'leaked'
  25. if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = "$1" ]; then
  26. msgpass
  27. else
  28. echo
  29. cat rootdir/tmp/testsuccess.output
  30. msgfail
  31. fi
  32. }
  33. checkinstall() {
  34. checkfdleak 8
  35. cp rootdir/tmp/testsuccess.output terminal.output
  36. tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
  37. testfileequal 'terminal.log' "$(cat terminal.output)"
  38. testequal "startup archives unpack
  39. install $PKGNAME <none> 1.0
  40. status half-installed $PKGNAME 1.0
  41. status unpacked $PKGNAME 1.0
  42. status unpacked $PKGNAME 1.0
  43. startup packages configure
  44. configure $PKGNAME 1.0 <none>
  45. status unpacked $PKGNAME 1.0
  46. status half-configured $PKGNAME 1.0
  47. status installed $PKGNAME 1.0
  48. startup packages configure" cut -f 3- -d' ' rootdir/var/log/dpkg.log
  49. }
  50. checkinstall
  51. rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
  52. testsuccess aptget purge -y fdleaks -qq
  53. checkpurge() {
  54. checkfdleak 12
  55. cp rootdir/tmp/testsuccess.output terminal.output
  56. tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
  57. testfileequal 'terminal.log' "$(cat terminal.output)"
  58. testequal "startup packages purge
  59. status installed $PKGNAME 1.0
  60. remove $PKGNAME 1.0 <none>
  61. status half-configured $PKGNAME 1.0
  62. status half-installed $PKGNAME 1.0
  63. status config-files $PKGNAME 1.0
  64. purge $PKGNAME 1.0 <none>
  65. status config-files $PKGNAME 1.0
  66. status config-files $PKGNAME 1.0
  67. status config-files $PKGNAME 1.0
  68. status config-files $PKGNAME 1.0
  69. status config-files $PKGNAME 1.0
  70. status not-installed $PKGNAME <none>
  71. startup packages configure" cut -f 3- -d' ' rootdir/var/log/dpkg.log
  72. }
  73. checkpurge
  74. msgtest 'setsid provided is new enough to support' '-w'
  75. if dpkg-checkbuilddeps -d 'util-linux (>= 2.24.2-1)' /dev/null >/dev/null 2>&1; then
  76. msgpass
  77. else
  78. msgskip "$(command dpkg -l util-linux)"
  79. exit
  80. fi
  81. rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
  82. testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" install -y fdleaks -qq < /dev/null
  83. checkinstall
  84. rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
  85. testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq
  86. checkpurge