Blame build-aux/test-driver

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