aboutsummaryrefslogtreecommitdiff
path: root/contrib/test_recheck
blob: 193cd3df2a3cb376508636b59e776da5f0b4e9fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /bin/sh

# (C) 2010 Free Software Foundation
# Written by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.

# This script is Free Software, and it can be copied, distributed and
# modified as defined in the GNU General Public License.  A copy of
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html

PROGNAME=test_recheck

usage ()
{
  cat <<EOF
Usage: $PROGNAME [-h] [-n] DIR|FILE.sum...

Rerun unsuccessful tests for testsuites below DIR or for FILE.sum.

  -h     display this help and exit
  -n     dry run, only show what would be run
EOF
  exit $?
}

error ()
{
  echo "$@" >&2
  exit 1
}

dry=
for arg
do
  case $arg in
    -h | \?) usage ;;
    -n) dry=:; shift ;;
    -*) error "unknown argument $arg" ;;
    *)  break ;;
  esac
done
test $# -gt 0 || usage

# Find a good awk.
if test -z "$AWK" ; then
  for AWK in gawk nawk awk
  do
    if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
      :
    else
      break
    fi
  done
fi

: ${MAKE=make}
: ${filesuffix=}
cwd=`pwd`
files=`find "$@" -name \*.sum$filesuffix -print | grep testsuite | sort`
st=0

for file in $files; do
  dir=`echo $file | sed 's,/[^/]*$,,'`
  base=`echo $file | sed 's,.*/,,; s,\.sum$,,'`
  flags=`$AWK '
/^Running .*\.exp \.\.\./ {
  if (expfile != "" && tests != "")
    printf (" %s=\"%s\"", expfile, tests)
  expfile = $2
  sub (/^[^ ]*\//, "", expfile)
  sep = ""
  tests = ""
}
/^(FAIL|XPASS|UNRESOLVED|WARNING|ERROR): / {
  if (test != $2 "" && $2 != "" ) {
    test = $2
    tests = tests sep test
    sep = " "
  }
}
END {
  if (expfile != "" && tests != "")
    printf (" %s=\"%s\"", expfile, tests)
}' $file`
  if test -n "$flags"; then
    cd $dir
    amflags=
    if grep '^AM_RUNTESTFLAGS =' Makefile >/dev/null 2>&1; then
      amflags=`echo 'print-runtestflags: ; @echo $(AM_RUNTESTFLAGS)' \
		 | ${MAKE} -s -f Makefile -f - print-runtestflags`
    fi
    echo "(cd $dir && runtest $amflags --tool $base $flags)"
    if test -z "$dry"; then
      eval runtest --tool $base $flags || st=$?
    fi
    cd "$cwd"
  fi
done
exit $st