Blame test-driver

Packit Service 6d40f9
#! /bin/sh
Packit Service 6d40f9
# test-driver - basic testsuite driver script.
Packit Service 6d40f9
Packit Service 6d40f9
scriptversion=2013-07-13.22; # UTC
Packit Service 6d40f9
Packit Service 6d40f9
# Copyright (C) 2011-2014 Free Software Foundation, Inc.
Packit Service 6d40f9
#
Packit Service 6d40f9
# This program is free software; you can redistribute it and/or modify
Packit Service 6d40f9
# it under the terms of the GNU General Public License as published by
Packit Service 6d40f9
# the Free Software Foundation; either version 2, or (at your option)
Packit Service 6d40f9
# any later version.
Packit Service 6d40f9
#
Packit Service 6d40f9
# This program is distributed in the hope that it will be useful,
Packit Service 6d40f9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 6d40f9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 6d40f9
# GNU General Public License for more details.
Packit Service 6d40f9
#
Packit Service 6d40f9
# You should have received a copy of the GNU General Public License
Packit Service 6d40f9
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 6d40f9
Packit Service 6d40f9
# As a special exception to the GNU General Public License, if you
Packit Service 6d40f9
# distribute this file as part of a program that contains a
Packit Service 6d40f9
# configuration script generated by Autoconf, you may include it under
Packit Service 6d40f9
# the same distribution terms that you use for the rest of that program.
Packit Service 6d40f9
Packit Service 6d40f9
# This file is maintained in Automake, please report
Packit Service 6d40f9
# bugs to <bug-automake@gnu.org> or send patches to
Packit Service 6d40f9
# <automake-patches@gnu.org>.
Packit Service 6d40f9
Packit Service 6d40f9
# Make unconditional expansion of undefined variables an error.  This
Packit Service 6d40f9
# helps a lot in preventing typo-related bugs.
Packit Service 6d40f9
set -u
Packit Service 6d40f9
Packit Service 6d40f9
usage_error ()
Packit Service 6d40f9
{
Packit Service 6d40f9
  echo "$0: $*" >&2
Packit Service 6d40f9
  print_usage >&2
Packit Service 6d40f9
  exit 2
Packit Service 6d40f9
}
Packit Service 6d40f9
Packit Service 6d40f9
print_usage ()
Packit Service 6d40f9
{
Packit Service 6d40f9
  cat <
Packit Service 6d40f9
Usage:
Packit Service 6d40f9
  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
Packit Service 6d40f9
              [--expect-failure={yes|no}] [--color-tests={yes|no}]
Packit Service 6d40f9
              [--enable-hard-errors={yes|no}] [--]
Packit Service 6d40f9
              TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
Packit Service 6d40f9
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
Packit Service 6d40f9
END
Packit Service 6d40f9
}
Packit Service 6d40f9
Packit Service 6d40f9
test_name= # Used for reporting.
Packit Service 6d40f9
log_file=  # Where to save the output of the test script.
Packit Service 6d40f9
trs_file=  # Where to save the metadata of the test run.
Packit Service 6d40f9
expect_failure=no
Packit Service 6d40f9
color_tests=no
Packit Service 6d40f9
enable_hard_errors=yes
Packit Service 6d40f9
while test $# -gt 0; do
Packit Service 6d40f9
  case $1 in
Packit Service 6d40f9
  --help) print_usage; exit $?;;
Packit Service 6d40f9
  --version) echo "test-driver $scriptversion"; exit $?;;
Packit Service 6d40f9
  --test-name) test_name=$2; shift;;
Packit Service 6d40f9
  --log-file) log_file=$2; shift;;
Packit Service 6d40f9
  --trs-file) trs_file=$2; shift;;
Packit Service 6d40f9
  --color-tests) color_tests=$2; shift;;
Packit Service 6d40f9
  --expect-failure) expect_failure=$2; shift;;
Packit Service 6d40f9
  --enable-hard-errors) enable_hard_errors=$2; shift;;
Packit Service 6d40f9
  --) shift; break;;
Packit Service 6d40f9
  -*) usage_error "invalid option: '$1'";;
Packit Service 6d40f9
   *) break;;
Packit Service 6d40f9
  esac
Packit Service 6d40f9
  shift
Packit Service 6d40f9
done
Packit Service 6d40f9
Packit Service 6d40f9
missing_opts=
Packit Service 6d40f9
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
Packit Service 6d40f9
test x"$log_file"  = x && missing_opts="$missing_opts --log-file"
Packit Service 6d40f9
test x"$trs_file"  = x && missing_opts="$missing_opts --trs-file"
Packit Service 6d40f9
if test x"$missing_opts" != x; then
Packit Service 6d40f9
  usage_error "the following mandatory options are missing:$missing_opts"
Packit Service 6d40f9
fi
Packit Service 6d40f9
Packit Service 6d40f9
if test $# -eq 0; then
Packit Service 6d40f9
  usage_error "missing argument"
Packit Service 6d40f9
fi
Packit Service 6d40f9
Packit Service 6d40f9
if test $color_tests = yes; then
Packit Service 6d40f9
  # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
Packit Service 6d40f9
  red='?[0;31m' # Red.
Packit Service 6d40f9
  grn='?[0;32m' # Green.
Packit Service 6d40f9
  lgn='?[1;32m' # Light green.
Packit Service 6d40f9
  blu='?[1;34m' # Blue.
Packit Service 6d40f9
  mgn='?[0;35m' # Magenta.
Packit Service 6d40f9
  std='?[m'     # No color.
Packit Service 6d40f9
else
Packit Service 6d40f9
  red= grn= lgn= blu= mgn= std=
Packit Service 6d40f9
fi
Packit Service 6d40f9
Packit Service 6d40f9
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
Packit Service 6d40f9
trap "st=129; $do_exit" 1
Packit Service 6d40f9
trap "st=130; $do_exit" 2
Packit Service 6d40f9
trap "st=141; $do_exit" 13
Packit Service 6d40f9
trap "st=143; $do_exit" 15
Packit Service 6d40f9
Packit Service 6d40f9
# Test script is run here.
Packit Service 6d40f9
"$@" >$log_file 2>&1
Packit Service 6d40f9
estatus=$?
Packit Service 6d40f9
Packit Service 6d40f9
if test $enable_hard_errors = no && test $estatus -eq 99; then
Packit Service 6d40f9
  tweaked_estatus=1
Packit Service 6d40f9
else
Packit Service 6d40f9
  tweaked_estatus=$estatus
Packit Service 6d40f9
fi
Packit Service 6d40f9
Packit Service 6d40f9
case $tweaked_estatus:$expect_failure in
Packit Service 6d40f9
  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
Packit Service 6d40f9
  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
Packit Service 6d40f9
  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
Packit Service 6d40f9
  99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;
Packit Service 6d40f9
  *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;
Packit Service 6d40f9
  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
Packit Service 6d40f9
esac
Packit Service 6d40f9
Packit Service 6d40f9
# Report the test outcome and exit status in the logs, so that one can
Packit Service 6d40f9
# know whether the test passed or failed simply by looking at the '.log'
Packit Service 6d40f9
# file, without the need of also peaking into the corresponding '.trs'
Packit Service 6d40f9
# file (automake bug#11814).
Packit Service 6d40f9
echo "$res $test_name (exit status: $estatus)" >>$log_file
Packit Service 6d40f9
Packit Service 6d40f9
# Report outcome to console.
Packit Service 6d40f9
echo "${col}${res}${std}: $test_name"
Packit Service 6d40f9
Packit Service 6d40f9
# Register the test result, and other relevant metadata.
Packit Service 6d40f9
echo ":test-result: $res" > $trs_file
Packit Service 6d40f9
echo ":global-test-result: $res" >> $trs_file
Packit Service 6d40f9
echo ":recheck: $recheck" >> $trs_file
Packit Service 6d40f9
echo ":copy-in-global-log: $gcopy" >> $trs_file
Packit Service 6d40f9
Packit Service 6d40f9
# Local Variables:
Packit Service 6d40f9
# mode: shell-script
Packit Service 6d40f9
# sh-indentation: 2
Packit Service 6d40f9
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit Service 6d40f9
# time-stamp-start: "scriptversion="
Packit Service 6d40f9
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit Service 6d40f9
# time-stamp-time-zone: "UTC"
Packit Service 6d40f9
# time-stamp-end: "; # UTC"
Packit Service 6d40f9
# End: