2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
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)
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.
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/>.
18 # Test driver for a very simple test protocol used by the Automake
19 # testsuite to check support for custom test drivers allowing for more
20 # test results per test script.
22 # The exit status of the wrapped script is ignored. Lines in its stdout
23 # and stderr beginning with 'PASS', 'FAIL', 'XFAIL', 'XPASS', 'SKIP' or
24 # 'ERROR' count as a test case result with the obviously-corresponding
25 # outcome. Every other line is ignored for what concerns the testsuite
28 # This script is used at least by the 'driver-custom-multitest*.test'
32 # Help to avoid typo-related bugs.
37 test_name=INVALID.NAME
40 while test $# -gt 0; do
42 --test-name) test_name=$2; shift;;
43 --log-file) log_file=$2; shift;;
44 --trs-file) trs_file=$2; shift;;
46 --expect-failure) shift;;
47 --color-tests) shift;;
48 --enable-hard-errors) shift;;
49 # Explicitly terminate option list.
52 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
59 echo "RUN: $test_name"
60 echo "RUN: $test_name" | sed 's/./=/g'
64 ## Run the test script, get test cases results, display them on console.
66 "$@" 2>&1 | tee -a $log_file | (
72 PASS:*) result=PASS ;;
73 FAIL:*) result=FAIL ;;
74 XPASS:*) result=XPASS ;;
75 XFAIL:*) result=XFAIL ;;
76 SKIP:*) result=SKIP ;;
77 ERROR:*) result=ERROR ;;
79 if test -n "$result"; then
80 case $result in FAIL|XPASS|ERROR) st=1;; esac
81 # Output testcase result to console.
82 echo "$result: $test_name"
83 # Register testcase outcome for the log file.
84 echo ":test-result: $line" >&5
88 if test $st -eq 0; then
93 copy_in_global_log=yes
95 echo ":recheck: $recheck" >&5
96 echo ":copy-in-global-log: $copy_in_global_log" >&5
98 ) | awk '{ print $0 ", testcase " NR }'