blob: f57e4a2532d95f14c9eeb9afb7f339492ec5b6ac (
plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#!/usr/bin/env bash
source odl_utils.sh
TESTS_DIR=tests
function help
{
echo "Run all ONE tests"
echo
echo This must be run with superuser privileges.
echo "Usage:"
echo " ./run.sh [vhc] [--config-method vat|cli]"
echo
echo " -v : verbose output"
echo " -c : clean"
echo " -h : show help"
echo " --config-method : select configuration method. Default is VAT."
}
export CFG_METHOD=vat
source config.sh
verbose=0
while [ $# -gt 0 ] ; do
arg=$1
shift
if [ $arg == "-v" ]; then
verbose=1
elif [ $arg == "-h" ] ; then
help
exit 0
elif [ $arg == "-c" ] ; then
clean_all
exit 0
elif [ $arg == "--config-method" ] ; then
type=$1
shift
if [ $type != "vat" -a $type != "cli" ] ; then
echo "ERROR: expected one of 'cli' or 'vat' "
help
exit 1
fi
export CFG_METHOD=$type
else
echo "parse error"
help
exit 1
fi
done
### begin script
failed_tcs=()
count=0
failed_num=0
passed_num=0
start_time=`date +%s`
# sudo?
if [[ $(id -u) != 0 ]]; then
echo "Superuser privileges needed!"
exit 1
fi
# check whether ODL is running
check_odl_running
# count tests
test_num=`ls -l "$TESTS_DIR"/test_* | wc -l`
echo
echo "Running VPP lite test suite."
echo
echo "Config method: $CFG_METHOD"
echo
for test_case in "$TESTS_DIR"/test_*
do
let "count=$count + 1"
# run the test case
base_name=`basename -a "$test_case"`
printf "*** %2d/%d : %-45s" $count $test_num "$base_name"
if [ $verbose -ne 0 ] ; then
"$test_case"
else
"$test_case" &> /dev/null
fi
rc=$?
if [ $rc -ne 0 ] ; then
printf "failed!\n"
failed_tcs+=("$test_case")
let "failed_num=$failed_num + 1"
else
printf "passed.\n"
let "passed_num=$passed_num + 1"
fi
sleep 1
done
end_time=`date +%s`
runtime=$((end_time-start_time))
echo
echo "------------------------------------------------------"
echo "Runtime: " `date -u -d @${runtime} +"%M min %S sec"`
echo
if [ $failed_num -eq 0 ]; then
echo "All tests have passed."
else
echo "List of failed test cases:"
for tc in "${failed_tcs[@]}"
do
echo "$tc"
done
fi
echo "------------------------------------------------------"
### end script
|