test-all.sh 2.5 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'

27 28
totalFailed=0
totalPyFailed=0
sangshuduo's avatar
sangshuduo 已提交
29 30


31
current_dir=`pwd`
sangshuduo's avatar
sangshuduo 已提交
32

33 34 35
if [ "$2" != "python" ]; then
  echo "### run TSIM test case ###"
  cd $current_dir/script
36

37 38 39 40 41 42 43 44 45 46 47
  [ -f out.log ] && rm -f out.log
  if [ "$1" == "cron" ]; then
    echo "### run TSIM regression test ###"
    runSimCaseOneByOne regressionSuite.sim
  elif [ "$1" == "full" ]; then
    echo "### run TSIM full test ###"
    runSimCaseOneByOne fullGeneralSuite.sim
  else
    echo "### run TSIM smoke test ###"
    runSimCaseOneByOne basicSuite.sim
  fi
48

49 50
  totalSuccess=`grep 'success' out.log | wc -l`
  totalBasic=`grep success out.log | grep Suite | wc -l`
51

52 53 54
  if [ "$totalSuccess" -gt "0" ]; then
    totalSuccess=`expr $totalSuccess - $totalBasic`
  fi
sangshuduo's avatar
sangshuduo 已提交
55

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

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

61 62
  if [ "$totalFailed" -ne "0" ]; then
    echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
sangshuduo's avatar
sangshuduo 已提交
63

64 65
#  exit $totalFailed
  fi
sangshuduo's avatar
sangshuduo 已提交
66 67
fi

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
if [ "$2" != "sim" ]; then
  echo "### run Python test case ###"
  cd $current_dir/pytest

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

  if [ "$1" == "cron" ]; then
    echo "### run Python regression test ###"
    runPyCaseOneByOne regressiontest.sh
  elif [ "$1" == "full" ]; then
    echo "### run Python full test ###"
    runPyCaseOneByOne fulltest.sh
  else
    echo "### run Python smoke test ###"
    runPyCaseOneByOne smoketest.sh
  fi
  totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l`

  if [ "$totalPySuccess" -gt "0" ]; then
    echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
  fi

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

97
exit $(($totalFailed + $totalPyFailed))