test-all.sh 2.3 KB
Newer Older
sangshuduo's avatar
sangshuduo 已提交
1 2
#!/bin/bash

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
function runSimCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^run.* ]]; then
      case=`echo $line | awk '{print $2}'`
      ./test.sh -f $case 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee -a out.log
    fi
  done < $1
}

function runPyCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^python.* ]]; then
      $line 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee -a pytest-out.log
    fi
  done < $1
}

sangshuduo's avatar
sangshuduo 已提交
20 21 22 23 24 25 26
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

S
Shuduo Sang 已提交
27
echo "### run TSIM test case ###"
sangshuduo's avatar
sangshuduo 已提交
28
cd script
29 30 31

[ -f out.log ] && rm -f out.log

32
if [ "$1" == "cron" ]; then
S
Shuduo Sang 已提交
33 34 35 36
  echo "### run TSIM regression test ###"
  runSimCaseOneByOne regressionSuite.sim
elif [ "$1" == "full" ]; then
  echo "### run TSIM full test ###"
37
  runSimCaseOneByOne fullGeneralSuite.sim
38
else
S
Shuduo Sang 已提交
39
  echo "### run TSIM smoke test ###"
40
  runSimCaseOneByOne basicSuite.sim
41
fi
sangshuduo's avatar
sangshuduo 已提交
42

43 44
totalSuccess=`grep 'success' out.log | wc -l`
totalBasic=`grep success out.log | grep Suite | wc -l`
sangshuduo's avatar
sangshuduo 已提交
45

46 47
if [ "$totalSuccess" -gt "0" ]; then
  totalSuccess=`expr $totalSuccess - $totalBasic`
sangshuduo's avatar
sangshuduo 已提交
48 49
fi

50 51
echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}"

52
totalFailed=`grep 'failed\|fault' out.log | wc -l`
53
# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
54

55
if [ "$totalFailed" -ne "0" ]; then
56 57 58
  echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"

#  exit $totalFailed
sangshuduo's avatar
sangshuduo 已提交
59 60
fi

S
Shuduo Sang 已提交
61
echo "### run Python test case ###"
sangshuduo's avatar
sangshuduo 已提交
62
cd ../pytest
63

64 65
[ -f pytest-out.log ] && rm -f pytest-out.log

66
if [ "$1" == "cron" ]; then
S
Shuduo Sang 已提交
67 68 69 70
  echo "### run Python regression test ###"
  runPyCaseOneByOne regressiontest.sh
elif [ "$1" == "full" ]; then
  echo "### run Python full test ###"
71
  runPyCaseOneByOne fulltest.sh
72
else
S
Shuduo Sang 已提交
73
  echo "### run Python smoke test ###"
74
  runPyCaseOneByOne smoketest.sh
75
fi
76
totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l`
sangshuduo's avatar
sangshuduo 已提交
77

78 79
if [ "$totalPySuccess" -gt "0" ]; then
  echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
sangshuduo's avatar
sangshuduo 已提交
80 81
fi

82
totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l`
83 84
if [ "$totalPyFailed" -ne "0" ]; then
  echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}"
85
#  exit $totalPyFailed
sangshuduo's avatar
sangshuduo 已提交
86 87
fi

88
exit $(($totalFailed + $totalPyFailed))