test-driver (302408) | test-driver (348980) |
---|---|
1#! /bin/sh 2# test-driver - basic testsuite driver script. 3 | 1#! /bin/sh 2# test-driver - basic testsuite driver script. 3 |
4scriptversion=2012-06-27.10; # UTC | 4scriptversion=2016-01-11.22; # UTC |
5 | 5 |
6# Copyright (C) 2011-2013 Free Software Foundation, Inc. | 6# Copyright (C) 2011-2017 Free Software Foundation, Inc. |
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, or (at your option) 11# 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 --- 24 unchanged lines hidden (view full) --- 39} 40 41print_usage () 42{ 43 cat <<END 44Usage: 45 test-driver --test-name=NAME --log-file=PATH --trs-file=PATH 46 [--expect-failure={yes|no}] [--color-tests={yes|no}] | 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, or (at your option) 11# 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 --- 24 unchanged lines hidden (view full) --- 39} 40 41print_usage () 42{ 43 cat <<END 44Usage: 45 test-driver --test-name=NAME --log-file=PATH --trs-file=PATH 46 [--expect-failure={yes|no}] [--color-tests={yes|no}] |
47 [--enable-hard-errors={yes|no}] [--] TEST-SCRIPT | 47 [--enable-hard-errors={yes|no}] [--] 48 TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] |
48The '--test-name', '--log-file' and '--trs-file' options are mandatory. 49END 50} 51 | 49The '--test-name', '--log-file' and '--trs-file' options are mandatory. 50END 51} 52 |
52# TODO: better error handling in option parsing (in particular, ensure 53# TODO: $log_file, $trs_file and $test_name are defined). | |
54test_name= # Used for reporting. 55log_file= # Where to save the output of the test script. 56trs_file= # Where to save the metadata of the test run. 57expect_failure=no 58color_tests=no 59enable_hard_errors=yes 60while test $# -gt 0; do 61 case $1 in 62 --help) print_usage; exit $?;; 63 --version) echo "test-driver $scriptversion"; exit $?;; 64 --test-name) test_name=$2; shift;; 65 --log-file) log_file=$2; shift;; 66 --trs-file) trs_file=$2; shift;; 67 --color-tests) color_tests=$2; shift;; 68 --expect-failure) expect_failure=$2; shift;; 69 --enable-hard-errors) enable_hard_errors=$2; shift;; 70 --) shift; break;; 71 -*) usage_error "invalid option: '$1'";; | 53test_name= # Used for reporting. 54log_file= # Where to save the output of the test script. 55trs_file= # Where to save the metadata of the test run. 56expect_failure=no 57color_tests=no 58enable_hard_errors=yes 59while test $# -gt 0; do 60 case $1 in 61 --help) print_usage; exit $?;; 62 --version) echo "test-driver $scriptversion"; exit $?;; 63 --test-name) test_name=$2; shift;; 64 --log-file) log_file=$2; shift;; 65 --trs-file) trs_file=$2; shift;; 66 --color-tests) color_tests=$2; shift;; 67 --expect-failure) expect_failure=$2; shift;; 68 --enable-hard-errors) enable_hard_errors=$2; shift;; 69 --) shift; break;; 70 -*) usage_error "invalid option: '$1'";; |
71 *) break;; |
|
72 esac 73 shift 74done 75 | 72 esac 73 shift 74done 75 |
76missing_opts= 77test x"$test_name" = x && missing_opts="$missing_opts --test-name" 78test x"$log_file" = x && missing_opts="$missing_opts --log-file" 79test x"$trs_file" = x && missing_opts="$missing_opts --trs-file" 80if test x"$missing_opts" != x; then 81 usage_error "the following mandatory options are missing:$missing_opts" 82fi 83 84if test $# -eq 0; then 85 usage_error "missing argument" 86fi 87 |
|
76if test $color_tests = yes; then 77 # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. 78 red='[0;31m' # Red. 79 grn='[0;32m' # Green. 80 lgn='[1;32m' # Light green. 81 blu='[1;34m' # Blue. 82 mgn='[0;35m' # Magenta. 83 std='[m' # No color. --- 5 unchanged lines hidden (view full) --- 89trap "st=129; $do_exit" 1 90trap "st=130; $do_exit" 2 91trap "st=141; $do_exit" 13 92trap "st=143; $do_exit" 15 93 94# Test script is run here. 95"$@" >$log_file 2>&1 96estatus=$? | 88if test $color_tests = yes; then 89 # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. 90 red='[0;31m' # Red. 91 grn='[0;32m' # Green. 92 lgn='[1;32m' # Light green. 93 blu='[1;34m' # Blue. 94 mgn='[0;35m' # Magenta. 95 std='[m' # No color. --- 5 unchanged lines hidden (view full) --- 101trap "st=129; $do_exit" 1 102trap "st=130; $do_exit" 2 103trap "st=141; $do_exit" 13 104trap "st=143; $do_exit" 15 105 106# Test script is run here. 107"$@" >$log_file 2>&1 108estatus=$? |
109 |
|
97if test $enable_hard_errors = no && test $estatus -eq 99; then | 110if test $enable_hard_errors = no && test $estatus -eq 99; then |
98 estatus=1 | 111 tweaked_estatus=1 112else 113 tweaked_estatus=$estatus |
99fi 100 | 114fi 115 |
101case $estatus:$expect_failure in | 116case $tweaked_estatus:$expect_failure in |
102 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 103 0:*) col=$grn res=PASS recheck=no gcopy=no;; 104 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 105 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; 106 *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; 107 *:*) col=$red res=FAIL recheck=yes gcopy=yes;; 108esac 109 | 117 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 118 0:*) col=$grn res=PASS recheck=no gcopy=no;; 119 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 120 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; 121 *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; 122 *:*) col=$red res=FAIL recheck=yes gcopy=yes;; 123esac 124 |
125# Report the test outcome and exit status in the logs, so that one can 126# know whether the test passed or failed simply by looking at the '.log' 127# file, without the need of also peaking into the corresponding '.trs' 128# file (automake bug#11814). 129echo "$res $test_name (exit status: $estatus)" >>$log_file 130 |
|
110# Report outcome to console. 111echo "${col}${res}${std}: $test_name" 112 113# Register the test result, and other relevant metadata. 114echo ":test-result: $res" > $trs_file 115echo ":global-test-result: $res" >> $trs_file 116echo ":recheck: $recheck" >> $trs_file 117echo ":copy-in-global-log: $gcopy" >> $trs_file 118 119# Local Variables: 120# mode: shell-script 121# sh-indentation: 2 122# eval: (add-hook 'write-file-hooks 'time-stamp) 123# time-stamp-start: "scriptversion=" 124# time-stamp-format: "%:y-%02m-%02d.%02H" | 131# Report outcome to console. 132echo "${col}${res}${std}: $test_name" 133 134# Register the test result, and other relevant metadata. 135echo ":test-result: $res" > $trs_file 136echo ":global-test-result: $res" >> $trs_file 137echo ":recheck: $recheck" >> $trs_file 138echo ":copy-in-global-log: $gcopy" >> $trs_file 139 140# Local Variables: 141# mode: shell-script 142# sh-indentation: 2 143# eval: (add-hook 'write-file-hooks 'time-stamp) 144# time-stamp-start: "scriptversion=" 145# time-stamp-format: "%:y-%02m-%02d.%02H" |
125# time-stamp-time-zone: "UTC" | 146# time-stamp-time-zone: "UTC0" |
126# time-stamp-end: "; # UTC" 127# End: | 147# time-stamp-end: "; # UTC" 148# End: |