annotate src/opus-1.3/test-driver @ 69:7aeed7906520

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