Blame config/test-driver

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