summaryrefslogtreecommitdiff
path: root/pbuilder/hooks/B20autopkgtest
blob: da49ff3b70fc298be1abedd46d275f5d10aefe71 (plain)
  1. #!/bin/bash
  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. OPTS="${AUTOPKGTEST_OPTIONS:-$ADT_OPTIONS}"
  41. if [ -n "${OPTS}" ]; then
  42. echo "*** Using provided AUTOPKGTEST_OPTIONS ${OPTS} ***"
  43. fi
  44. # try to launch autopkgtest in a new PID namespace so several testsuites can run
  45. # in parallel, newpid exists in jessie and newer only though
  46. unset newpid_name
  47. if ! apt-cache policy newpid | grep -q 'newpid:' ; then
  48. echo "The newpid package doesn't seem to be available, not considering for installation"
  49. else
  50. echo "The newpid package seems to be available, considering for installation"
  51. newpid_name='newpid'
  52. fi
  53. # runner/adt-run uses apt-utils's apt-ftparchive and
  54. # pbuilder's pbuilder-satisfydepends-classic
  55. apt-get install -y "${APTGETOPT[@]}" autopkgtest apt-utils pbuilder $newpid_name
  56. mkdir -p "$BUILDDIR/autopkgtest.out"
  57. if which autopkgtest >/dev/null; then
  58. $newpid_name autopkgtest \
  59. --output-dir "$BUILDDIR/autopkgtest.out" \
  60. --summary "$BUILDDIR/autopkgtest.summary" \
  61. "$BUILDDIR"/*.deb \
  62. "${PWD}" \
  63. ${OPTS} -- autopkgtest-virt-null || EXIT=$?
  64. else
  65. # since autopkgtest 3.16 the --tmp-dir option is gone, make sure
  66. # we've --output-dir available though before using it
  67. if adt-run --help | grep -q -- --output-dir 2>/dev/null ; then
  68. OUTPUT_OPTION='--output-dir'
  69. else
  70. OUTPUT_OPTION='--tmp-dir'
  71. fi
  72. $newpid_name adt-run \
  73. ${OUTPUT_OPTION} "$BUILDDIR/autopkgtest.out" \
  74. --summary "$BUILDDIR/autopkgtest.summary" \
  75. "$BUILDDIR"/*.deb \
  76. --built-tree "${PWD}" \
  77. ${OPTS} --- adt-virt-null || EXIT=$?
  78. fi
  79. # collect autopkgtest output in a single file so pbuilder automatically copies it
  80. tar -caf "$BUILDDIR/autopkgtest.tar.gz" "$BUILDDIR/autopkgtest.out"
  81. case ${EXIT:-0} in
  82. 2|4|6|8) # let adtsummary_tap report the failure
  83. BUILDDIR="${BUILDDIR:-/tmp/buildd}"
  84. #apt-get install -y "${APTGETOPT[@]}" vim less
  85. cd "$BUILDDIR"/*/debian/..
  86. /bin/bash < /dev/tty > /dev/tty 2> /dev/tty
  87. exit 0
  88. ;;
  89. *)
  90. exit ${EXIT:-0}
  91. ;;
  92. esac