annotate src/opus-1.3/test-driver @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 #! /bin/sh
cannam@154 2 # test-driver - basic testsuite driver script.
cannam@154 3
cannam@154 4 scriptversion=2016-01-11.22; # UTC
cannam@154 5
cannam@154 6 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
cannam@154 7 #
cannam@154 8 # This program is free software; you can redistribute it and/or modify
cannam@154 9 # it under the terms of the GNU General Public License as published by
cannam@154 10 # the Free Software Foundation; either version 2, or (at your option)
cannam@154 11 # any later version.
cannam@154 12 #
cannam@154 13 # This program is distributed in the hope that it will be useful,
cannam@154 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@154 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@154 16 # GNU General Public License for more details.
cannam@154 17 #
cannam@154 18 # You should have received a copy of the GNU General Public License
cannam@154 19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@154 20
cannam@154 21 # As a special exception to the GNU General Public License, if you
cannam@154 22 # distribute this file as part of a program that contains a
cannam@154 23 # configuration script generated by Autoconf, you may include it under
cannam@154 24 # the same distribution terms that you use for the rest of that program.
cannam@154 25
cannam@154 26 # This file is maintained in Automake, please report
cannam@154 27 # bugs to <bug-automake@gnu.org> or send patches to
cannam@154 28 # <automake-patches@gnu.org>.
cannam@154 29
cannam@154 30 # Make unconditional expansion of undefined variables an error. This
cannam@154 31 # helps a lot in preventing typo-related bugs.
cannam@154 32 set -u
cannam@154 33
cannam@154 34 usage_error ()
cannam@154 35 {
cannam@154 36 echo "$0: $*" >&2
cannam@154 37 print_usage >&2
cannam@154 38 exit 2
cannam@154 39 }
cannam@154 40
cannam@154 41 print_usage ()
cannam@154 42 {
cannam@154 43 cat <<END
cannam@154 44 Usage:
cannam@154 45 test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
cannam@154 46 [--expect-failure={yes|no}] [--color-tests={yes|no}]
cannam@154 47 [--enable-hard-errors={yes|no}] [--]
cannam@154 48 TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
cannam@154 49 The '--test-name', '--log-file' and '--trs-file' options are mandatory.
cannam@154 50 END
cannam@154 51 }
cannam@154 52
cannam@154 53 test_name= # Used for reporting.
cannam@154 54 log_file= # Where to save the output of the test script.
cannam@154 55 trs_file= # Where to save the metadata of the test run.
cannam@154 56 expect_failure=no
cannam@154 57 color_tests=no
cannam@154 58 enable_hard_errors=yes
cannam@154 59 while test $# -gt 0; do
cannam@154 60 case $1 in
cannam@154 61 --help) print_usage; exit $?;;
cannam@154 62 --version) echo "test-driver $scriptversion"; exit $?;;
cannam@154 63 --test-name) test_name=$2; shift;;
cannam@154 64 --log-file) log_file=$2; shift;;
cannam@154 65 --trs-file) trs_file=$2; shift;;
cannam@154 66 --color-tests) color_tests=$2; shift;;
cannam@154 67 --expect-failure) expect_failure=$2; shift;;
cannam@154 68 --enable-hard-errors) enable_hard_errors=$2; shift;;
cannam@154 69 --) shift; break;;
cannam@154 70 -*) usage_error "invalid option: '$1'";;
cannam@154 71 *) break;;
cannam@154 72 esac
cannam@154 73 shift
cannam@154 74 done
cannam@154 75
cannam@154 76 missing_opts=
cannam@154 77 test x"$test_name" = x && missing_opts="$missing_opts --test-name"
cannam@154 78 test x"$log_file" = x && missing_opts="$missing_opts --log-file"
cannam@154 79 test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
cannam@154 80 if test x"$missing_opts" != x; then
cannam@154 81 usage_error "the following mandatory options are missing:$missing_opts"
cannam@154 82 fi
cannam@154 83
cannam@154 84 if test $# -eq 0; then
cannam@154 85 usage_error "missing argument"
cannam@154 86 fi
cannam@154 87
cannam@154 88 if test $color_tests = yes; then
cannam@154 89 # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
cannam@154 90 red='' # Red.
cannam@154 91 grn='' # Green.
cannam@154 92 lgn='' # Light green.
cannam@154 93 blu='' # Blue.
cannam@154 94 mgn='' # Magenta.
cannam@154 95 std='' # No color.
cannam@154 96 else
cannam@154 97 red= grn= lgn= blu= mgn= std=
cannam@154 98 fi
cannam@154 99
cannam@154 100 do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
cannam@154 101 trap "st=129; $do_exit" 1
cannam@154 102 trap "st=130; $do_exit" 2
cannam@154 103 trap "st=141; $do_exit" 13
cannam@154 104 trap "st=143; $do_exit" 15
cannam@154 105
cannam@154 106 # Test script is run here.
cannam@154 107 "$@" >$log_file 2>&1
cannam@154 108 estatus=$?
cannam@154 109
cannam@154 110 if test $enable_hard_errors = no && test $estatus -eq 99; then
cannam@154 111 tweaked_estatus=1
cannam@154 112 else
cannam@154 113 tweaked_estatus=$estatus
cannam@154 114 fi
cannam@154 115
cannam@154 116 case $tweaked_estatus:$expect_failure in
cannam@154 117 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
cannam@154 118 0:*) col=$grn res=PASS recheck=no gcopy=no;;
cannam@154 119 77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
cannam@154 120 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
cannam@154 121 *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
cannam@154 122 *:*) col=$red res=FAIL recheck=yes gcopy=yes;;
cannam@154 123 esac
cannam@154 124
cannam@154 125 # Report the test outcome and exit status in the logs, so that one can
cannam@154 126 # know whether the test passed or failed simply by looking at the '.log'
cannam@154 127 # file, without the need of also peaking into the corresponding '.trs'
cannam@154 128 # file (automake bug#11814).
cannam@154 129 echo "$res $test_name (exit status: $estatus)" >>$log_file
cannam@154 130
cannam@154 131 # Report outcome to console.
cannam@154 132 echo "${col}${res}${std}: $test_name"
cannam@154 133
cannam@154 134 # Register the test result, and other relevant metadata.
cannam@154 135 echo ":test-result: $res" > $trs_file
cannam@154 136 echo ":global-test-result: $res" >> $trs_file
cannam@154 137 echo ":recheck: $recheck" >> $trs_file
cannam@154 138 echo ":copy-in-global-log: $gcopy" >> $trs_file
cannam@154 139
cannam@154 140 # Local Variables:
cannam@154 141 # mode: shell-script
cannam@154 142 # sh-indentation: 2
cannam@154 143 # eval: (add-hook 'write-file-hooks 'time-stamp)
cannam@154 144 # time-stamp-start: "scriptversion="
cannam@154 145 # time-stamp-format: "%:y-%02m-%02d.%02H"
cannam@154 146 # time-stamp-time-zone: "UTC0"
cannam@154 147 # time-stamp-end: "; # UTC"
cannam@154 148 # End: