forked from aaSSfxxx/r2-regressions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·99 lines (85 loc) · 2.19 KB
/
run_tests.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# Copyright (C) 2011-2015 pancake <[email protected]>
# Copyright (C) 2011-2012 Edd Barrett <[email protected]>
# Copyright (C) 2012 Simon Ruderich <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cd `dirname $0` 2>/dev/null
radare2 -v
if [ $? != 0 ]; then
echo "Cannot find radare2"
exit 1
fi
# Statistics.
TESTS_TOTAL=0
TESTS_SUCCESS=0
TESTS_FAILED=0
TESTS_BROKEN=0
TESTS_FIXED=0
TESTS_FATAL=0
# Let tests.sh know the complete test suite is run, enables statistics.
R2_SOURCED=1
control_c() {
echo
exit 1
}
trap control_c 2
. ./tests.sh
radare2 > /dev/null
if [ $? != 0 ]; then
echo "Cannot find radare2"
exit 1
fi
R=$PWD
# Run all tests.
T="t"; [ -n "$1" ] && T="$1"
if [ -f "$T" -a -x "$T" ]; then
BDIR=`dirname $T`
FILE=`basename $T`
cd $BDIR
. ./$FILE
else
cd $T || die "t/ doesn't exist"
do_tests_recurse() {
# Tests are run recursively
for i in "$1"/*; do
if [ -d "$i" ]; then
cd ${i}
do_tests_recurse "."
cd ..
elif [ -f "$i" ]; then
if [ ! -x "$i" ]; then # Only run files marked as executable.
print_found_nonexec "$i"
else
NAME=`basename $i`
TEST_NAME=${NAME}
. ./${i}
fi
fi
done
}
do_tests_recurse "."
fi
print_report
save_stats
# Exit codes, as documented in README.md
if [ "${TESTS_FATAL}" -gt 0 ]; then
echo "ESSENTIAL TEST HAS FAILED"
exit 1
elif [ "${TESTS_FAILED}" -gt 0 ]; then
exit 2
else
exit 0
fi