test_recheck 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #! /bin/sh
  2. # (C) 2010 Free Software Foundation
  3. # Written by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
  4. # This script is Free Software, and it can be copied, distributed and
  5. # modified as defined in the GNU General Public License. A copy of
  6. # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
  7. PROGNAME=test_recheck
  8. usage ()
  9. {
  10. cat <<EOF
  11. Usage: $PROGNAME [-h] [-n] DIR|FILE.sum...
  12. Rerun unsuccessful tests for testsuites below DIR or for FILE.sum.
  13. -h display this help and exit
  14. -n dry run, only show what would be run
  15. EOF
  16. exit $?
  17. }
  18. error ()
  19. {
  20. echo "$@" >&2
  21. exit 1
  22. }
  23. dry=
  24. for arg
  25. do
  26. case $arg in
  27. -h | \?) usage ;;
  28. -n) dry=:; shift ;;
  29. -*) error "unknown argument $arg" ;;
  30. *) break ;;
  31. esac
  32. done
  33. test $# -gt 0 || usage
  34. # Find a good awk.
  35. if test -z "$AWK" ; then
  36. for AWK in gawk nawk awk
  37. do
  38. if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
  39. :
  40. else
  41. break
  42. fi
  43. done
  44. fi
  45. : ${MAKE=make}
  46. : ${filesuffix=}
  47. cwd=`pwd`
  48. files=`find "$@" -name \*.sum$filesuffix -print | grep testsuite | sort`
  49. st=0
  50. for file in $files; do
  51. dir=`echo $file | sed 's,/[^/]*$,,'`
  52. base=`echo $file | sed 's,.*/,,; s,\.sum$,,'`
  53. flags=`$AWK '
  54. /^Running .*\.exp \.\.\./ {
  55. if (expfile != "" && tests != "")
  56. printf (" %s=\"%s\"", expfile, tests)
  57. expfile = $2
  58. sub (/^[^ ]*\//, "", expfile)
  59. sep = ""
  60. tests = ""
  61. }
  62. /^(FAIL|XPASS|UNRESOLVED|WARNING|ERROR): / {
  63. if (test != $2 "" && $2 != "" ) {
  64. test = $2
  65. tests = tests sep test
  66. sep = " "
  67. }
  68. }
  69. END {
  70. if (expfile != "" && tests != "")
  71. printf (" %s=\"%s\"", expfile, tests)
  72. }' $file`
  73. if test -n "$flags"; then
  74. cd $dir
  75. amflags=
  76. if grep '^AM_RUNTESTFLAGS =' Makefile >/dev/null 2>&1; then
  77. amflags=`echo 'print-runtestflags: ; @echo $(AM_RUNTESTFLAGS)' \
  78. | ${MAKE} -s -f Makefile -f - print-runtestflags`
  79. fi
  80. echo "(cd $dir && runtest $amflags --tool $base $flags)"
  81. if test -z "$dry"; then
  82. eval runtest --tool $base $flags || st=$?
  83. fi
  84. cd "$cwd"
  85. fi
  86. done
  87. exit $st