summaryrefslogtreecommitdiff
path: root/pbuilder/hooks/B20autopkgtest
blob: 27c4ac28232d7f081302368559b4b06a0363cd92 (plain)
  1. #!/bin/sh
  2. # Copyright © 2012 Christoph Berg <myon@debian.org>
  3. # © 2013 Michael Prokop <mika@debian.org>
  4. # © 2015 Mattia Rizzolo <mattia@mapreri.org>
  5. #
  6. # This file is part of pbuilder -- personal Debian package builder
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. BUILDDIR="${BUILDDIR:-/tmp/buildd}"
  22. if [ "${ADT:-}" = "skip" ]; then
  23. echo "Skipping autopkgtests as requested (ADT is set to 'skip')"
  24. exit 0
  25. fi
  26. if [ "${ADT:-}" = "external" ]; then
  27. echo "Skipping internal autopkgtests as external testing was requested via ADT variable"
  28. exit 0
  29. fi
  30. set -ex
  31. cd "$BUILDDIR"/*/debian/..
  32. if [ ! -f debian/tests/control ]; then
  33. echo "Package does not have autopkgtest support, debian/tests/control is missing"
  34. exit 0
  35. fi
  36. if [ ! -f debian/files ]; then
  37. echo "Package source is not built, debian/files is missing" >&2
  38. exit 1
  39. fi
  40. if [ -n "${ADT_OPTIONS:-}" ] ; then
  41. echo "*** Using provided ADT_OPTIONS $ADT_OPTIONS ***"
  42. fi
  43. # try to launch adt-run in a new PID namespace so several testsuites can run
  44. # in parallel, newpid exists in jessie and newer only though
  45. unset newpid_name
  46. if ! apt-cache policy newpid | grep -q 'newpid:' ; then
  47. echo "The newpid package doesn't seem to be available, not considering for installation"
  48. else
  49. echo "The newpid package seems to be available, considering for installation"
  50. newpid_name='newpid'
  51. fi
  52. # runner/adt-run uses apt-utils's apt-ftparchive and
  53. # pbuilder's pbuilder-satisfydepends-classic
  54. apt-get install -y autopkgtest apt-utils pbuilder $newpid_name
  55. # since autopkgtest 3.16 the --tmp-dir option is gone, make sure
  56. # we've --output-dir available though before using it
  57. if adt-run --help | grep -q -- --output-dir 2>/dev/null ; then
  58. OUTPUT_OPTION='--output-dir'
  59. else
  60. OUTPUT_OPTION='--tmp-dir'
  61. fi
  62. mkdir -p "$BUILDDIR/autopkgtest.out"
  63. $newpid_name adt-run \
  64. ${OUTPUT_OPTION} "$BUILDDIR/autopkgtest.out" \
  65. --summary "$BUILDDIR/autopkgtest.summary" \
  66. "$BUILDDIR"/*.deb \
  67. --built-tree "${PWD}" \
  68. ${ADT_OPTIONS:-} --- adt-virt-null || EXIT=$?
  69. # collect autopkgtest output in a single file so pbuilder automatically copies it
  70. tar -caf "$BUILDDIR/autopkgtest.tar.gz" "$BUILDDIR/autopkgtest.out"
  71. case ${EXIT:-0} in
  72. 2|4|6|8) # let adtsummary_tap report the failure
  73. BUILDDIR="${BUILDDIR:-/tmp/buildd}"
  74. #apt-get install -y "${APTGETOPT[@]}" vim less
  75. cd "$BUILDDIR"/*/debian/..
  76. /bin/bash < /dev/tty > /dev/tty 2> /dev/tty
  77. exit 0
  78. ;;
  79. *)
  80. exit ${EXIT:-0}
  81. ;;
  82. esac