Blame mini-gmp/tests/run-tests

Packit 5c3484
#! /bin/sh
Packit 5c3484
Packit 5c3484
# Copyright (C) 2000-2002, 2004, 2005, 2011, 2012, 2016  Niels Möller
Packit 5c3484
#
Packit 5c3484
# This program is free software; you can redistribute it and/or modify
Packit 5c3484
# it under the terms of the GNU General Public License as published by
Packit 5c3484
# the Free Software Foundation; either version 2 of the License, or
Packit 5c3484
# (at your option) any later version.
Packit 5c3484
#
Packit 5c3484
# This program is distributed in the hope that it will be useful,
Packit 5c3484
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5c3484
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 5c3484
# GNU General Public License for more details.
Packit 5c3484
#
Packit 5c3484
# You should have received a copy of the GNU General Public License along
Packit 5c3484
# with this program; if not, write to the Free Software Foundation, Inc.,
Packit 5c3484
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 5c3484
Packit 5c3484
failed=0
Packit 5c3484
all=0
Packit 5c3484
Packit 5c3484
debug='no'
Packit 5c3484
testflags=''
Packit 5c3484
Packit 5c3484
if [ -z "$srcdir" ] ; then
Packit 5c3484
  srcdir=`pwd`
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
export srcdir
Packit 5c3484
Packit 5c3484
# When used in make rules, we sometimes get the filenames VPATH
Packit 5c3484
# expanded, but usually not.
Packit 5c3484
find_program () {
Packit 5c3484
    case "$1" in
Packit 5c3484
	*/*)
Packit 5c3484
	  echo "$1"
Packit 5c3484
	  ;;
Packit 5c3484
	*)
Packit 5c3484
	  if [ -x "$1" ] ; then
Packit 5c3484
	      echo "./$1"
Packit 5c3484
	  else
Packit 5c3484
	      echo "$srcdir/$1"
Packit 5c3484
	  fi
Packit 5c3484
	  ;;
Packit 5c3484
    esac
Packit 5c3484
}
Packit 5c3484
Packit 5c3484
env_program () {
Packit 5c3484
  if [ -x "$1" ] ; then
Packit 5c3484
    if "$1"; then : ; else
Packit 5c3484
      echo FAIL: $1
Packit 5c3484
      exit 1
Packit 5c3484
    fi
Packit 5c3484
  fi
Packit 5c3484
}
Packit 5c3484
Packit 5c3484
TEST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
Packit 5c3484
TEST_DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
Packit 5c3484
Packit 5c3484
if [ "$TEST_LIBRARY_PATH" ] ; then
Packit 5c3484
  TEST_LD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_LD_LIBRARY_PATH"
Packit 5c3484
  TEST_DYLD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_DYLD_LIBRARY_PATH"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
test_program () {
Packit 5c3484
  testname=`basename "$1" .exe`
Packit 5c3484
  testname=`basename "$testname" -test`
Packit 5c3484
  if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then
Packit 5c3484
    LD_LIBRARY_PATH="$TEST_LD_LIBRARY_PATH" \
Packit 5c3484
    DYLD_LIBRARY_PATH="$TEST_DYLD_LIBRARY_PATH" \
Packit 5c3484
    "$1" $testflags
Packit 5c3484
  else
Packit 5c3484
    $EMULATOR "$1" $testflags
Packit 5c3484
  fi
Packit 5c3484
  case "$?" in
Packit 5c3484
      0)
Packit 5c3484
	echo PASS: $testname
Packit 5c3484
	all=`expr $all + 1`
Packit 5c3484
	;;
Packit 5c3484
      77)
Packit 5c3484
	echo SKIP: $testname
Packit 5c3484
      ;;
Packit 5c3484
      *)
Packit 5c3484
	echo FAIL: $testname
Packit 5c3484
	failed=`expr $failed + 1`
Packit 5c3484
	all=`expr $all + 1`
Packit 5c3484
	;;
Packit 5c3484
  esac
Packit 5c3484
}
Packit 5c3484
Packit 5c3484
env_program `find_program setup-env`
Packit 5c3484
Packit 5c3484
while test $# != 0
Packit 5c3484
do
Packit 5c3484
  case "$1" in
Packit 5c3484
  --debug)
Packit 5c3484
    debug=yes
Packit 5c3484
    ;;
Packit 5c3484
  -v)
Packit 5c3484
    testflags='-v'
Packit 5c3484
    ;;
Packit 5c3484
  -*)
Packit 5c3484
    echo >&2 'Unknown option `'"$1'"
Packit 5c3484
    exit 1
Packit 5c3484
    ;;
Packit 5c3484
  *)
Packit 5c3484
    break
Packit 5c3484
    ;;
Packit 5c3484
  esac
Packit 5c3484
  shift
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
# Comment out special handling for zero arguments to support separate
Packit 5c3484
# tests-build/tests-run.
Packit 5c3484
#if [ $# -eq 0 ] ; then
Packit 5c3484
#  for f in *-test; do test_program "./$f"; done
Packit 5c3484
#else
Packit 5c3484
  for f in "$@" ; do test_program `find_program "$f"`; done
Packit 5c3484
#fi
Packit 5c3484
Packit 5c3484
if [ $failed -eq 0 ] ; then
Packit 5c3484
  banner="All $all tests passed"
Packit 5c3484
else
Packit 5c3484
  banner="$failed of $all tests failed"
Packit 5c3484
fi
Packit 5c3484
dashes=`echo "$banner" | sed s/./=/g`
Packit 5c3484
echo "$dashes"
Packit 5c3484
echo "$banner"
Packit 5c3484
echo "$dashes"
Packit 5c3484
Packit 5c3484
if [ "x$debug" = xno ] ; then
Packit 5c3484
  env_program `find_program teardown-env`
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
[ "$failed" -eq 0 ]