2
0

parallel-tests-exit-statuses.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Check parallel-tests features: normal and special exit statuses
  17. # in the test scripts.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_OUTPUT
  21. END
  22. # $failure_statuses should be defined to the list of all integers between
  23. # 1 and 255 (inclusive), excluded 77 and 99.
  24. failure_statuses=$(seq_ 1 255 | $EGREP -v '^(77|99)$' | tr "$nl" ' ')
  25. # For debugging.
  26. echo "failure_statuses: $failure_statuses"
  27. # Sanity check.
  28. test $(for st in $failure_statuses; do echo $st; done | wc -l) -eq 253 \
  29. || fatal_ "initializing list of exit statuses for simple failures"
  30. cat > Makefile.am <<END
  31. LOG_COMPILER = $AM_TEST_RUNNER_SHELL ./do-exit
  32. fail_tests = $failure_statuses
  33. TESTS = 0 77 99 $failure_statuses
  34. \$(TESTS):
  35. END
  36. cat > do-exit <<'END'
  37. #!/bin/sh
  38. echo "$0: $1"
  39. case $1 in
  40. [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) st=$1;;
  41. */[0-9]|*/[0-9][0-9]|*/[0-9][0-9][0-9]) st=${1##*/};;
  42. *) st=99;;
  43. esac
  44. exit $st
  45. END
  46. chmod a+x do-exit
  47. $ACLOCAL
  48. $AUTOCONF
  49. $AUTOMAKE -a
  50. {
  51. echo PASS: 0
  52. echo SKIP: 77
  53. echo ERROR: 99
  54. for st in $failure_statuses; do
  55. echo "FAIL: $st"
  56. done
  57. } | LC_ALL=C sort > exp-0
  58. sed 's/^FAIL:/XFAIL:/' exp-0 | LC_ALL=C sort > exp-1
  59. sed '/^ERROR:/d' exp-1 > exp-2
  60. ./configure
  61. mk_ ()
  62. {
  63. n=$1; shift
  64. unset am_make_rc
  65. run_make -e IGNORE -O -- ${1+"$@"} check
  66. cat test-suite.log
  67. LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-$n
  68. cat exp-$n
  69. cat got-$n
  70. diff exp-$n got-$n
  71. }
  72. mk_ 0
  73. test $am_make_rc -gt 0
  74. mk_ 1 XFAIL_TESTS="$failure_statuses 99"
  75. test $am_make_rc -gt 0
  76. mk_ 2 XFAIL_TESTS="$failure_statuses" TESTS="0 77 $failure_statuses"
  77. test $am_make_rc -eq 0
  78. :