-
Notifications
You must be signed in to change notification settings - Fork 11
/
do_test
executable file
·78 lines (63 loc) · 1.51 KB
/
do_test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#! /bin/bash
#
# The korn shell will also be able to interpret this script. The Andrew
# shell ash won't because of the arithmetics used.
#
# do_test: Perform MiNTLib tests.
#set -x
trap 'rm -f /tmp/$$*' 1 2 3 15
checks="$*"
failed=0
passed=0
status=0
if test "x$checks" = x; then
echo "No tests to perform."
exit 1
fi
perform_test () {
shortcheck=$1
check=test-$shortcheck
cmd=./$check
test -f $check.sh && cmd="./$check.sh"
test -f $check.args && cmd="$cmd $(<$check.args)"
test -f $check.input && cmd="$cmd <$check.input"
test -f $check.expect && cmd="$cmd >|/tmp/$$.output" \
|| cmd="$cmd >/dev/null"
test "x$TEST_VERBOSE" != "x" && echo "$cmd"
printf "Doing test $shortcheck ... "
eval $cmd
status=$?
if test $status = 0; then
if test -f $check.expect; then
test "x$TEST_VERBOSE" != x && echo \
"cmp /tmp/$$.output $check.expect >/dev/null"
cmp /tmp/$$.output $check.expect >/dev/null
status=$?
fi
fi
rm -f /tmp/$$.output
return $status
}
for check in $checks; do
perform_test $check
if test $? = 0; then
let passed=$(($passed + 1))
echo "PASS"
else
let failed=$(($failed + 1))
echo "FAIL"
status=1
fi
done
total=$(($failed + $passed))
if test $failed = 0; then
echo "===== All $passed tests passed. ====="
elif test $passed = 0; then
echo "*** All $failed tests failed. ***"
elif test $failed = 1; then
echo "*** one tiny little test of $total failed. ***"
else
echo "*** $failed tests of $total failed. ***"
fi
rm -f /tmp/$$*
exit $status