forked from wenshao/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·72 lines (68 loc) · 1.26 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
#!/bin/bash
#
# AUTHOR: Zhifeng YANG
# DATE: 2011-08-16
# DESCRIPTION: run all tests in the `tests/' directory
#
function usage()
{
echo "run_tests.sh [--print-failed] [test_name_pattern]"
echo "Example: run_tests.sh "
echo " run_tests.sh --print-failed"
echo " run_tests.sh base_main_test"
echo " run_tests.sh --print-failed rootserver"
exit 1
}
# parse command line
OPT_PRINT_FAILED=0
TEST_NAME_PATTERN=""
if [ $# -eq 0 ]
then
true
elif [ $# -eq 1 ]
then
if [ $1 = "--print-failed" ]
then
OPT_PRINT_FAILED=1
elif [ $1 = "--help" -o $1 = "-h" ]
then
usage
else
TEST_NAME_PATTERN=$1
fi
elif [ $# -eq 2 ]
then
if [ $1 = "--print-failed" ]
then
OPT_PRINT_FAILED=1
TEST_NAME_PATTERN=$2
else
usage
fi
else
usage
fi
TESTS=`find tests/ -type f -perm /100 \( -name "test_*" -o -name "*_test" \)`
TOPDIR=`pwd`
LOGFILE=$TOPDIR/run_tests.log
for T in $TESTS
do
if [ -n $TEST_NAME_PATTERN ]
then
case $T in
*${TEST_NAME_PATTERN}*) ;;
*) continue ;;
esac
fi
D=`dirname $T`
F=`basename $T`
echo "[****************] RUN TEST $F IN $D"
cd $D
if [ $OPT_PRINT_FAILED ]
then
./$F 2>&1 |tee -a $LOGFILE|egrep "FAILED"
else
./$F 2>&1 |tee -a $LOGFILE|egrep "(\[==========|\[----------|PASSED|FAILED)"
fi
cd $TOPDIR
done