test.sh 4.4 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/bin/bash

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

set +e
S
Shengliang Guan 已提交
10
#set -x
11 12 13 14 15 16 17 18

FILE_NAME=
RELEASE=0
ASYNC=0
VALGRIND=0
UNIQUE=0
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
S
Shengliang Guan 已提交
19
while getopts "f:agvum" arg
20 21 22 23 24 25 26 27 28 29 30
do
  case $arg in
    f)
      FILE_NAME=$OPTARG
      ;;
    v)
      VALGRIND=1
      ;;
    u)
      UNIQUE=1
      ;;
S
Shengliang Guan 已提交
31 32 33
    g)
      VALGRIND=2
      ;;  
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    ?)
      echo "unknow argument"
      ;;
  esac
done

cd .

# Get responsible directories
CODE_DIR=`dirname $0`
CODE_DIR=`pwd`

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

TOP_DIR=`pwd`
wafwerar's avatar
wafwerar 已提交
54
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
55 56 57 58 59 60 61 62

if [[ "$OS_TYPE" != "Darwin" ]]; then
  cut_opt="--field="
else
  cut_opt="-f "
fi

if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
wafwerar's avatar
wafwerar 已提交
63
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
64
else
wafwerar's avatar
wafwerar 已提交
65
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
66 67
fi

wafwerar's avatar
wafwerar 已提交
68 69 70
declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR
declare -x SIM_DIR=$TOP_DIR/sim
PROGRAM=$BUILD_DIR/build/bin/tsim
71 72 73 74
PRG_DIR=$SIM_DIR/tsim
CFG_DIR=$PRG_DIR/cfg
LOG_DIR=$PRG_DIR/log
DATA_DIR=$PRG_DIR/data
S
Shengliang Guan 已提交
75
ASAN_DIR=$SIM_DIR/asan
76 77 78 79 80 81 82 83

chmod -R 777 $PRG_DIR
echo "------------------------------------------------------------------------"
echo "Start TDengine Testing Case ..."
echo "BUILD_DIR: $BUILD_DIR"
echo "SIM_DIR  : $SIM_DIR"
echo "CODE_DIR : $CODE_DIR"
echo "CFG_DIR  : $CFG_DIR"
S
Shengliang Guan 已提交
84
echo "ASAN_DIR  : $ASAN_DIR"
85

P
plum-lihui 已提交
86
rm -rf $SIM_DIR/*
87 88
rm -rf $LOG_DIR
rm -rf $CFG_DIR
S
Shengliang Guan 已提交
89
rm -rf $ASAN_DIR
90 91 92 93

mkdir -p $PRG_DIR
mkdir -p $LOG_DIR
mkdir -p $CFG_DIR
S
Shengliang Guan 已提交
94
mkdir -p $ASAN_DIR
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

TAOS_CFG=$PRG_DIR/cfg/taos.cfg
touch -f $TAOS_CFG
TAOS_FLAG=$PRG_DIR/flag

#HOSTNAME=`hostname -f`
HOSTNAME=localhost

echo " "                                          >> $TAOS_CFG
echo "firstEp            ${HOSTNAME}:7100"        >> $TAOS_CFG
echo "secondEp           ${HOSTNAME}:7200"        >> $TAOS_CFG
echo "serverPort         7100"                    >> $TAOS_CFG
echo "dataDir            $DATA_DIR"               >> $TAOS_CFG
echo "logDir             $LOG_DIR"                >> $TAOS_CFG
echo "scriptDir          ${CODE_DIR}"             >> $TAOS_CFG
echo "numOfLogLines      100000000"               >> $TAOS_CFG
echo "rpcDebugFlag       143"                     >> $TAOS_CFG
echo "tmrDebugFlag       131"                     >> $TAOS_CFG
echo "cDebugFlag         143"                     >> $TAOS_CFG
echo "udebugFlag         143"                     >> $TAOS_CFG
echo "debugFlag          143"                     >> $TAOS_CFG
echo "wal                0"                       >> $TAOS_CFG
echo "asyncLog           0"                       >> $TAOS_CFG
echo "locale             en_US.UTF-8"             >> $TAOS_CFG
echo "enableCoreFile     1"                       >> $TAOS_CFG
echo " "                                          >> $TAOS_CFG

ulimit -n 600000
ulimit -c unlimited

#sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e

if [ -n "$FILE_NAME" ]; then
  echo "------------------------------------------------------------------------"
  if [ $VALGRIND -eq 1 ]; then
130
    FLAG="-v"
X
Xiaoyu Wang 已提交
131 132
    echo valgrind --tool=memcheck --leak-check=full --show-reachable=no  --track-origins=yes --child-silent-after-fork=yes --show-leak-kinds=all --num-callers=20 -v  --workaround-gcc296-bugs=yes  --log-file=${LOG_DIR}/valgrind-tsim.log $PROGRAM -c $CFG_DIR -f $FILE_NAME $FLAG
    valgrind --tool=memcheck --leak-check=full --show-reachable=no  --track-origins=yes --child-silent-after-fork=yes --show-leak-kinds=all --num-callers=20 -v  --workaround-gcc296-bugs=yes  --log-file=${LOG_DIR}/valgrind-tsim.log $PROGRAM -c $CFG_DIR -f $FILE_NAME $FLAG
S
Shengliang Guan 已提交
133 134 135
  elif [ $VALGRIND -eq 2 ]; then
    echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME -v
    $PROGRAM -c $CFG_DIR -f $FILE_NAME -v
136
  else
S
Shengliang Guan 已提交
137
    echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME
S
Shengliang Guan 已提交
138 139
    echo "AsanDir:" $ASAN_DIR/tsim.asan
    eval $PROGRAM -c $CFG_DIR -f $FILE_NAME 2> $ASAN_DIR/tsim.asan
S
Shengliang Guan 已提交
140
    result=$?
S
Shengliang Guan 已提交
141
    echo "Execute result:" $result
S
Shengliang Guan 已提交
142 143 144 145

    if [ $result -eq 0 ]; then
      $CODE_DIR/sh/checkAsan.sh
    else
S
Shengliang Guan 已提交
146 147 148
      echo "TSIM has asan errors"
      sleep 1
      $CODE_DIR/sh/checkAsan.sh
S
Shengliang Guan 已提交
149 150
      exit 1
    fi
151 152 153 154 155 156 157
  fi
else
  echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim
  echo "------------------------------------------------------------------------"
  $PROGRAM -c $CFG_DIR -f basicSuite.sim
fi