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

3 4 5 6 7 8 9
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

10 11 12
function runSimCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^run.* ]]; then
13 14 15 16
      case=`echo $line | awk '{print $NF}'`
      ./test.sh -f $case > /dev/null && \
        echo -e "${GREEN}$case success${NC}" || \
        echo -e "${RED}$case failed${NC}" | tee -a out.log
17 18 19 20 21 22 23
    fi
  done < $1
}

function runPyCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^python.* ]]; then
24 25 26 27 28 29 30 31
      if [[ $line != *sleep* ]]; then
        case=`echo $line|awk '{print $NF}'`
        $line > /dev/null 2>&1 && \
          echo -e "${GREEN}$case success${NC}" || \
          echo -e "${RED}$case failed${NC}" | tee -a pytest-out.log
      else
        $line > /dev/null 2>&1
      fi
32 33 34 35
    fi
  done < $1
}

36 37
totalFailed=0
totalPyFailed=0
sangshuduo's avatar
sangshuduo 已提交
38

39
current_dir=`pwd`
sangshuduo's avatar
sangshuduo 已提交
40

41 42 43
if [ "$2" != "python" ]; then
  echo "### run TSIM test case ###"
  cd $current_dir/script
44

45 46 47 48 49 50 51
  [ -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
S
Shuduo Sang 已提交
52
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
53 54 55
    echo "### run TSIM smoke test ###"
    runSimCaseOneByOne basicSuite.sim
  fi
56

57 58
  totalSuccess=`grep 'success' out.log | wc -l`
  totalBasic=`grep success out.log | grep Suite | wc -l`
59

60 61 62
  if [ "$totalSuccess" -gt "0" ]; then
    totalSuccess=`expr $totalSuccess - $totalBasic`
  fi
sangshuduo's avatar
sangshuduo 已提交
63

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

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

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

72 73
#  exit $totalFailed
  fi
sangshuduo's avatar
sangshuduo 已提交
74 75
fi

76 77
if [ "$2" != "sim" ]; then
  echo "### run Python test case ###"
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

  IN_TDINTERNAL="community"

  if [[ "$current_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../..
  else
    cd ../
  fi

  TOP_DIR=`pwd`
  TAOSLIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1`
  if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then
    LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4,5`
  else
    LIB_DIR=`find . -name "libtaos.so"|grep -w lib|head -n1|cut -d '/' --fields=2,3,4`
  fi

  export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH

97 98 99 100 101 102 103 104 105 106
  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
S
Shuduo Sang 已提交
107
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
108 109 110
    echo "### run Python smoke test ###"
    runPyCaseOneByOne smoketest.sh
  fi
111
  totalPySuccess=`grep 'success' pytest-out.log | wc -l`
112 113 114 115 116 117 118 119

  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}"
120
#  exit $totalPyFailed
121
  fi
sangshuduo's avatar
sangshuduo 已提交
122 123
fi

124
exit $(($totalFailed + $totalPyFailed))