runAllSimCases.sh 2.3 KB
Newer Older
P
plum-lihui 已提交
1
#!/bin/bash
P
plum-lihui 已提交
2 3 4 5 6 7 8 9 10

##################################################
# 
# Do simulation test 
#
##################################################

set -e
#set -x
11 12
VALGRIND=0
LOG_BK_DIR=/data/valgrind_log_backup     # 192.168.0.203
P
plum-lihui 已提交
13 14 15
SIM_FILES=./jenkins/basic.txt

while getopts "v:r:f:" arg
16 17 18 19 20 21 22 23
do
  case $arg in
    v)
      VALGRIND=1
      ;;
    r)
      LOG_BK_DIR=$(echo $OPTARG)
      ;;
P
plum-lihui 已提交
24 25 26
    f)
      SIM_FILES=$(echo $OPTARG)
      ;;
27 28 29 30 31 32 33 34
    ?) #unknow option
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

echo "VALGRIND: $VALGRIND, LOG_BK_DIR: $LOG_BK_DIR"
P
plum-lihui 已提交
35
echo "SIM_FILES: $SIM_FILES"
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

CURRENT_DIR=`pwd`
TSIM_LOG_DIR=$CURRENT_DIR/../../sim/tsim/log
TAOSD_LOG_DIR=$CURRENT_DIR/../../sim

echo "tsim  log dir: $TSIM_LOG_DIR"
echo "taosd log dir: $TAOSD_LOG_DIR"

if [[ $VALGRIND -eq 1 ]]; then
  if [ -d ${LOG_BK_DIR} ]; then
    rm -rf ${LOG_BK_DIR}/*
  else
    mkdir -p $LOG_BK_DIR/
  fi
fi
P
plum-lihui 已提交
51 52 53 54 55

while read line
do
  firstChar=`echo ${line:0:1}`
  if [[ -n "$line" ]]  && [[ $firstChar != "#" ]]; then
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    if [[ $VALGRIND -eq 1 ]]; then
      echo "======== $line -v ========" 
      $line -v 
      
      # move all valgrind log files of the sim case to valgrind back dir
      # get current sim case name for       
      result=`echo ${line%sim*}`
      result=`echo ${result#*/}`
      result=`echo ${result#*/}`
      result=`echo ${result////-}`
      tsimLogFile=valgrind-${result}sim.log

      echo "cp ${TSIM_LOG_DIR}/valgrind-tsim.log ${LOG_BK_DIR}/${tsimLogFile}    "
      cp ${TSIM_LOG_DIR}/valgrind-tsim.log ${LOG_BK_DIR}/${tsimLogFile}    
      cp ${TAOSD_LOG_DIR}/dnode1/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode2/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode3/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode4/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode5/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode6/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode7/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode8/log/valgrind*.log ${LOG_BK_DIR}/          ||:
      cp ${TAOSD_LOG_DIR}/dnode9/log/valgrind*.log ${LOG_BK_DIR}/          ||:

    else
      echo "======== $line ========"
      $line
    fi
P
plum-lihui 已提交
84
  fi
P
plum-lihui 已提交
85 86
done < ${SIM_FILES}
#done < ./jenkins/basic.txt
P
plum-lihui 已提交
87 88