diff --git a/tests/script/sh/checkAsan.sh b/tests/script/sh/checkAsan.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4801891edf4e8f26c1f96c93619a73244f1e849 --- /dev/null +++ b/tests/script/sh/checkAsan.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set +e +#set -x + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/../ +SCRIPT_DIR=`pwd` + +IN_TDINTERNAL="community" +if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TAOS_DIR=`pwd` +LOG_DIR=$TAOS_DIR/sim/tsim/asan + +error_num=`cat ${LOG_DIR}/tsim.asan | grep "ERROR" | wc -l` +memory_leak=`cat ${LOG_DIR}/tsim.asan | grep "Direct leak" | wc -l` +indirect_leak=`cat ${LOG_DIR}/tsim.asan | grep "Indirect leak" | wc -l` +runtime_error=`cat ${LOG_DIR}/tsim.asan | grep "runtime error" | wc -l` + +echo -e "\033[44;32;1m"asan error_num: $error_num"\033[0m" +echo -e "\033[44;32;1m"asan memory_leak: $memory_leak"\033[0m" +echo -e "\033[44;32;1m"asan indirect_leak: $indirect_leak"\033[0m" +echo -e "\033[44;32;1m"asan runtime error: $runtime_error"\033[0m" + +let "errors=$error_num+$memory_leak+$indirect_leak+$runtime_error" + +if [ $errors -eq 0 ]; then + echo -e "\033[44;32;1m"no asan errors"\033[0m" + exit 0 +else + echo -e "\033[44;31;1m"asan total errors: $errors"\033[0m" + cat ${LOG_DIR}/tsim.asan + exit 1 +fi \ No newline at end of file diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index 74015eebd64317006ae1c808d2fe37512bbf8b03..3f2c5d268cc9cdb49ae0e06e8ac7cbf366c520a3 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -80,7 +80,7 @@ LOG_DIR=$NODE_DIR/log DATA_DIR=$NODE_DIR/data MGMT_DIR=$NODE_DIR/data/mgmt TSDB_DIR=$NODE_DIR/data/tsdb - +ASAN_DIR=$SIM_DIR/tsim/asan TAOS_CFG=$NODE_DIR/cfg/taos.cfg echo ------------ $EXEC_OPTON $NODE_NAME @@ -105,7 +105,7 @@ if [ "$EXEC_OPTON" = "start" ]; then nohup valgrind --log-file=${LOG_DIR}/valgrind-taosd-${NODE_NAME}-${TT}.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & else echo "nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &" - nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & + nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2> $ASAN_DIR/$NODE_NAME.asan & fi else diff --git a/tests/script/test.sh b/tests/script/test.sh index b38d331715eb1de63c6819fc76990bfcced09a9e..ee6f6f6ab76629137a2c526d335a348de8afc318 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -74,6 +74,7 @@ PRG_DIR=$SIM_DIR/tsim CFG_DIR=$PRG_DIR/cfg LOG_DIR=$PRG_DIR/log DATA_DIR=$PRG_DIR/data +ASAN_DIR=$PRG_DIR/asan chmod -R 777 $PRG_DIR echo "------------------------------------------------------------------------" @@ -82,14 +83,17 @@ echo "BUILD_DIR: $BUILD_DIR" echo "SIM_DIR : $SIM_DIR" echo "CODE_DIR : $CODE_DIR" echo "CFG_DIR : $CFG_DIR" +echo "ASAN_DIR : $ASAN_DIR" rm -rf $SIM_DIR/* rm -rf $LOG_DIR rm -rf $CFG_DIR +rm -rf $ASAN_DIR mkdir -p $PRG_DIR mkdir -p $LOG_DIR mkdir -p $CFG_DIR +mkdir -p $ASAN_DIR TAOS_CFG=$PRG_DIR/cfg/taos.cfg touch -f $TAOS_CFG @@ -132,8 +136,9 @@ if [ -n "$FILE_NAME" ]; then echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME -v $PROGRAM -c $CFG_DIR -f $FILE_NAME -v else - echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME - $PROGRAM -c $CFG_DIR -f $FILE_NAME + echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME + $PROGRAM -c $CFG_DIR -f $FILE_NAME 2> $ASAN_DIR/tsim.asan + $TOP_DIR/tests/script/sh/checkAsan.sh fi else echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim