run.sh revision 05479d87
1#!/usr/bin/env bash
2
3TESTS_DIR=tests
4
5function 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
17verbose=0
18
19while [ $# -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
29done
30
31### begin script
32
33failed_tcs=()
34count=0
35failed_num=0
36passed_num=0
37
38start_time=`date +%s`
39
40# count tests
41test_num=`ls -l $TESTS_DIR/test_* | wc -l`
42
43echo
44echo "Running VPP lite test suite."
45echo
46
47for test_case in $TESTS_DIR/test_*
48do
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
71done
72
73end_time=`date +%s`
74runtime=$((end_time-start_time))
75
76echo
77echo "------------------------------------------------------"
78echo "Runtime: " `date -u -d @${runtime} +"%M min %S sec"`
79echo
80
81if [ $failed_num -eq 0 ]; then
82  echo "All tests have passed."
83else
84  echo "List of failed test cases:"
85  for tc in "${failed_tcs[@]}"
86  do
87    echo "$tc"
88  done
89fi
90
91echo "------------------------------------------------------"
92
93### end script
94