Small improvements
[one.git] / tests / data_plane / vpp_lite_topo / run.sh
1 #!/usr/bin/env bash
2
3 source config.sh
4 source odl_utils.sh
5
6 TESTS_DIR=tests
7
8 function help
9 {
10   echo "Run all ONE tests"
11   echo
12   echo This must be run with superuser privileges.
13   echo "Usage:"
14   echo " ./run.sh [vhc]"
15   echo
16   echo "  -v : verbose output"
17   echo "  -c : clean"
18   echo "  -h : show help"
19 }
20
21 verbose=0
22
23 while [ $# -gt 0 ] ; do
24   arg=$1
25   shift
26
27   if [ $arg == "-v" ]; then
28     verbose=1
29   elif [ $arg == "-h" ] ; then
30     help
31     exit 0
32   elif [ $arg == "-c" ] ; then
33     clean_all
34     exit 0
35   fi
36 done
37
38 ### begin script
39
40 failed_tcs=()
41 count=0
42 failed_num=0
43 passed_num=0
44
45 start_time=`date +%s`
46
47 # sudo?
48 if [[ $(id -u) != 0 ]]; then
49   echo "Superuser privileges needed!"
50   exit 1
51 fi
52
53 # check whether ODL is running
54 check_odl_running
55
56
57 # count tests
58 test_num=`ls -l "$TESTS_DIR"/test_* | wc -l`
59
60 echo
61 echo "Running VPP lite test suite."
62 echo
63
64 for test_case in "$TESTS_DIR"/test_*
65 do
66   let "count=$count + 1"
67
68   # run the test case
69   base_name=`basename -a "$test_case"`
70   printf "*** %2d/%d : %-45s" $count $test_num "$base_name"
71
72   if [ $verbose -ne 0 ] ; then
73     "$test_case"
74   else
75     "$test_case" &> /dev/null
76   fi
77   rc=$?
78
79   if [ $rc -ne 0 ] ; then
80     printf "failed!\n"
81     failed_tcs+=("$test_case")
82     let "failed_num=$failed_num + 1"
83   else
84     printf "passed.\n"
85     let "passed_num=$passed_num + 1"
86   fi
87   sleep 1
88 done
89
90 end_time=`date +%s`
91 runtime=$((end_time-start_time))
92
93 echo
94 echo "------------------------------------------------------"
95 echo "Runtime: " `date -u -d @${runtime} +"%M min %S sec"`
96 echo
97
98 if [ $failed_num -eq 0 ]; then
99   echo "All tests have passed."
100 else
101   echo "List of failed test cases:"
102   for tc in "${failed_tcs[@]}"
103   do
104     echo "$tc"
105   done
106 fi
107
108 echo "------------------------------------------------------"
109
110 ### end script