Blame config/test-driver

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