pytest.sh 1.9 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/bash

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

set +e
#set -x

UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`

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`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`

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

if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
else
  BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
fi

declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR
declare -x SIM_DIR=$TOP_DIR/sim
PROGRAM=$BUILD_DIR/build/bin/tsim
PRG_DIR=$SIM_DIR/tsim
S
Shengliang Guan 已提交
47
ASAN_DIR=$SIM_DIR/asan
S
Shengliang Guan 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61

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 "ASAN_DIR  : $ASAN_DIR"

rm -rf $SIM_DIR/*

mkdir -p $PRG_DIR
mkdir -p $ASAN_DIR

S
Shengliang Guan 已提交
62
cd $CODE_DIR
S
Shengliang Guan 已提交
63 64 65 66 67 68
ulimit -n 600000
ulimit -c unlimited

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

echo "ExcuteCmd:" $*
S
Shengliang Guan 已提交
69
AsanFile=$ASAN_DIR/psim.info
S
Shengliang Guan 已提交
70
echo "AsanFile:" $AsanFile
S
Shengliang Guan 已提交
71

S
Shengliang Guan 已提交
72
unset LD_PRELOAD
S
Shengliang Guan 已提交
73 74
#export LD_PRELOAD=libasan.so.5
export LD_PRELOAD=`gcc -print-file-name=libasan.so`
S
Shengliang Guan 已提交
75
echo "Preload AsanSo:" $?
S
Shengliang Guan 已提交
76

S
Shengliang Guan 已提交
77 78
$* -a 2> $AsanFile

S
Shengliang Guan 已提交
79
unset LD_PRELOAD
S
Shengliang Guan 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93
AsanFileLen=`cat $AsanFile | wc -l`
while [ $AsanFileLen -lt 10 ]
do
  sleep 1
  `cat $AsanFile | wc -l`
done 
echo "AsanFileLen:" $AsanFileLen

AsanFileSuccessLen=`grep -w successfully $AsanFile | wc -l`
echo "AsanFileSuccessLen:" $AsanFileSuccessLen

if [ $AsanFileSuccessLen -gt 0 ]; then
  echo "Execute script successfully and check asan"
  $CODE_DIR/../script/sh/checkAsan.sh
S
Shengliang Guan 已提交
94
else
S
Shengliang Guan 已提交
95
  echo "Execute script failure"
S
Shengliang Guan 已提交
96 97 98
  exit 1
fi