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