Blame SOURCES/libsodium-1.0.18/build-aux/test-driver

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