Blame test-driver

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