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

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