github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mini-gmp/tests/run-tests (about)

     1  #! /bin/sh
     2  
     3  # Copyright (C) 2000-2002, 2004, 2005, 2011, 2012, 2016  Niels Möller
     4  #
     5  # This program is free software; you can redistribute it and/or modify
     6  # it under the terms of the GNU General Public License as published by
     7  # the Free Software Foundation; either version 2 of the License, or
     8  # (at your option) any later version.
     9  #
    10  # This program is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  # GNU General Public License for more details.
    14  #
    15  # You should have received a copy of the GNU General Public License along
    16  # with this program; if not, write to the Free Software Foundation, Inc.,
    17  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    18  
    19  failed=0
    20  all=0
    21  
    22  debug='no'
    23  testflags=''
    24  
    25  if [ -z "$srcdir" ] ; then
    26    srcdir=`pwd`
    27  fi
    28  
    29  export srcdir
    30  
    31  # When used in make rules, we sometimes get the filenames VPATH
    32  # expanded, but usually not.
    33  find_program () {
    34      case "$1" in
    35  	*/*)
    36  	  echo "$1"
    37  	  ;;
    38  	*)
    39  	  if [ -x "$1" ] ; then
    40  	      echo "./$1"
    41  	  else
    42  	      echo "$srcdir/$1"
    43  	  fi
    44  	  ;;
    45      esac
    46  }
    47  
    48  env_program () {
    49    if [ -x "$1" ] ; then
    50      if "$1"; then : ; else
    51        echo FAIL: $1
    52        exit 1
    53      fi
    54    fi
    55  }
    56  
    57  TEST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
    58  TEST_DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
    59  
    60  if [ "$TEST_LIBRARY_PATH" ] ; then
    61    TEST_LD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_LD_LIBRARY_PATH"
    62    TEST_DYLD_LIBRARY_PATH="$TEST_LIBRARY_PATH:$TEST_DYLD_LIBRARY_PATH"
    63  fi
    64  
    65  test_program () {
    66    testname=`basename "$1" .exe`
    67    testname=`basename "$testname" -test`
    68    if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then
    69      LD_LIBRARY_PATH="$TEST_LD_LIBRARY_PATH" \
    70      DYLD_LIBRARY_PATH="$TEST_DYLD_LIBRARY_PATH" \
    71      "$1" $testflags
    72    else
    73      $EMULATOR "$1" $testflags
    74    fi
    75    case "$?" in
    76        0)
    77  	echo PASS: $testname
    78  	all=`expr $all + 1`
    79  	;;
    80        77)
    81  	echo SKIP: $testname
    82        ;;
    83        *)
    84  	echo FAIL: $testname
    85  	failed=`expr $failed + 1`
    86  	all=`expr $all + 1`
    87  	;;
    88    esac
    89  }
    90  
    91  env_program `find_program setup-env`
    92  
    93  while test $# != 0
    94  do
    95    case "$1" in
    96    --debug)
    97      debug=yes
    98      ;;
    99    -v)
   100      testflags='-v'
   101      ;;
   102    -*)
   103      echo >&2 'Unknown option `'"$1'"
   104      exit 1
   105      ;;
   106    *)
   107      break
   108      ;;
   109    esac
   110    shift
   111  done
   112  
   113  # Comment out special handling for zero arguments to support separate
   114  # tests-build/tests-run.
   115  #if [ $# -eq 0 ] ; then
   116  #  for f in *-test; do test_program "./$f"; done
   117  #else
   118    for f in "$@" ; do test_program `find_program "$f"`; done
   119  #fi
   120  
   121  if [ $failed -eq 0 ] ; then
   122    banner="All $all tests passed"
   123  else
   124    banner="$failed of $all tests failed"
   125  fi
   126  dashes=`echo "$banner" | sed s/./=/g`
   127  echo "$dashes"
   128  echo "$banner"
   129  echo "$dashes"
   130  
   131  if [ "x$debug" = xno ] ; then
   132    env_program `find_program teardown-env`
   133  fi
   134  
   135  [ "$failed" -eq 0 ]