Debian Codegraph @

mini-gmp/tests/run-tests

raw symbols SCIP
1 #! /bin/sh
2
3 # Copyright (C) 2000-2002, 2004, 2005, 2011, 2012, 2016, 2020 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 if [ -n "$TEST_SHLIB_DIR" ] ; then
32 # Prepend to LD_LIBRARY_PATH, if it is alredy set.
33 LD_LIBRARY_PATH="${TEST_SHLIB_DIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
34 # For MACOS
35 DYLD_LIBRARY_PATH="$TEST_SHLIB_DIR"
36 # For Windows
37 PATH="${TEST_SHLIB_DIR}:${PATH}"
38 # For Wine
39 WINEPATH="${TEST_SHLIB_DIR}${WINEPATH:+;$WINEPATH}"
40
41 export LD_LIBRARY_PATH
42 export DYLD_LIBRARY_PATH
43 export PATH
44 export WINEPATH
45 fi
46
47 # When used in make rules, we sometimes get the filenames VPATH
48 # expanded, but usually not.
49 find_program () {
50 case "$1" in
51 */*)
52 echo "$1"
53 ;;
54 *)
55 if [ -x "$1" ] ; then
56 echo "./$1"
57 elif [ -x "$1.exe" ] ; then
58 echo "./$1.exe"
59 else
60 echo "$srcdir/$1"
61 fi
62 ;;
63 esac
64 }
65
66 env_program () {
67 if [ -x "$1" ] ; then
68 if "$1"; then : ; else
69 echo FAIL: $1
70 exit 1
71 fi
72 fi
73 }
74
75 test_program () {
76 testname=`basename "$1" .exe`
77 testname=`basename "$testname" -test`
78 if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then
79 "$1" $testflags
80 else
81 $EMULATOR "$1" $testflags
82 fi
83 case "$?" in
84 0)
85 echo PASS: $testname
86 all=`expr $all + 1`
87 ;;
88 77)
89 echo SKIP: $testname
90 ;;
91 *)
92 echo FAIL: $testname
93 failed=`expr $failed + 1`
94 all=`expr $all + 1`
95 ;;
96 esac
97 }
98
99 env_program `find_program setup-env`
100
101 while test $# != 0
102 do
103 case "$1" in
104 --debug)
105 debug=yes
106 ;;
107 -v)
108 testflags='-v'
109 ;;
110 -*)
111 echo >&2 'Unknown option `'"$1'"
112 exit 1
113 ;;
114 *)
115 break
116 ;;
117 esac
118 shift
119 done
120
121 # Comment out special handling for zero arguments to support separate
122 # tests-build/tests-run.
123 #if [ $# -eq 0 ] ; then
124 # for f in *-test; do test_program "./$f"; done
125 #else
126 for f in "$@" ; do test_program `find_program "$f"`; done
127 #fi
128
129 if [ $failed -eq 0 ] ; then
130 banner="All $all tests passed"
131 else
132 banner="$failed of $all tests failed"
133 fi
134 dashes=`echo "$banner" | sed s/./=/g`
135 echo "$dashes"
136 echo "$banner"
137 echo "$dashes"
138
139 if [ "x$debug" = xno ] ; then
140 env_program `find_program teardown-env`
141 fi
142
143 [ "$failed" -eq 0 ]