pytest.sh 2.3 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10
#!/bin/bash

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

set +e
#set -x
sangshuduo's avatar
sangshuduo 已提交
11 12 13 14 15 16 17 18
if [[ "$OSTYPE" == "darwin"* ]]; then
  TD_OS="Darwin"
else
  OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2)
  len=$(echo ${#OS})
  len=$((len - 2))
  TD_OS=$(echo -ne ${OS:1:${len}} | cut -d" " -f1)
fi
S
Shengliang Guan 已提交
19

sangshuduo's avatar
sangshuduo 已提交
20 21
UNAME_BIN=$(which uname)
OS_TYPE=$($UNAME_BIN)
S
Shengliang Guan 已提交
22 23 24 25

cd .

# Get responsible directories
sangshuduo's avatar
sangshuduo 已提交
26 27
CODE_DIR=$(dirname $0)
CODE_DIR=$(pwd)
S
Shengliang Guan 已提交
28 29 30 31 32 33 34 35

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

sangshuduo's avatar
sangshuduo 已提交
36 37
TOP_DIR=$(pwd)
TAOSD_DIR=$(find . -name "taosd" | grep bin | head -n1)
S
Shengliang Guan 已提交
38

sangshuduo's avatar
sangshuduo 已提交
39
cut_opt="-f "
S
Shengliang Guan 已提交
40 41

if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
sangshuduo's avatar
sangshuduo 已提交
42
  BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2,3)
S
Shengliang Guan 已提交
43
else
sangshuduo's avatar
sangshuduo 已提交
44
  BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2)
S
Shengliang Guan 已提交
45 46 47 48 49 50
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 已提交
51
ASAN_DIR=$SIM_DIR/asan
S
Shengliang Guan 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65

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 已提交
66
cd $CODE_DIR
S
Shengliang Guan 已提交
67 68 69 70 71 72
ulimit -n 600000
ulimit -c unlimited

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

echo "ExcuteCmd:" $*
S
Shengliang Guan 已提交
73

sangshuduo's avatar
sangshuduo 已提交
74 75
if [[ "$TD_OS" == "Alpine" ]]; then
  $*
S
Shengliang Guan 已提交
76
else
sangshuduo's avatar
sangshuduo 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
  AsanFile=$ASAN_DIR/psim.info
  echo "AsanFile:" $AsanFile

  unset LD_PRELOAD
  #export LD_PRELOAD=libasan.so.5
  export LD_PRELOAD=$(gcc -print-file-name=libasan.so)
  echo "Preload AsanSo:" $?

  $* -a 2>$AsanFile

  unset LD_PRELOAD
  for ((i = 1; i <= 20; i++)); do
    AsanFileLen=$(cat $AsanFile | wc -l)
    echo "AsanFileLen:" $AsanFileLen
    if [ $AsanFileLen -gt 10 ]; then
      break
    fi
    sleep 1
  done
haoranc's avatar
haoranc 已提交
96
  # check case successful
haoranc's avatar
haoranc 已提交
97
  AsanFileSuccessLen=$(grep -w "successfully executed" $AsanFile | wc -l)
sangshuduo's avatar
sangshuduo 已提交
98 99 100 101 102 103 104 105 106
  echo "AsanFileSuccessLen:" $AsanFileSuccessLen

  if [ $AsanFileSuccessLen -gt 0 ]; then
    echo "Execute script successfully and check asan"
    $CODE_DIR/../script/sh/checkAsan.sh
  else
    echo "Execute script failure"
    exit 1
  fi
haoranc's avatar
haoranc 已提交
107
fi