From 4dc1b33414e918b90bc68f7b96228e129b088e30 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 20 Nov 2022 17:29:16 +0800 Subject: [PATCH] test: python asan --- tests/script/sh/checkAsan.sh | 1 + tests/script/sh/exec.sh | 1 + tests/script/sh/stop_dnodes.sh | 2 +- tests/system-test/test.py | 2 +- tests/system-test/test.sh | 32 +++++++++++++++++++++----------- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/script/sh/checkAsan.sh b/tests/script/sh/checkAsan.sh index 0ce74a989e..8e5738e911 100755 --- a/tests/script/sh/checkAsan.sh +++ b/tests/script/sh/checkAsan.sh @@ -3,6 +3,7 @@ set +e #set -x +export LD_PRELOAD= SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index 5ef4cca741..ad671631a9 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -11,6 +11,7 @@ set +e #set -x +export LD_PRELOAD= UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh index 38667d9b3f..34777ccb59 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -3,10 +3,10 @@ set +e #set -x +export LD_PRELOAD= UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` -export LD_PRELOAD= PID=`ps -ef|grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then echo systemctl stop taosd diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 712b9689ba..cf9aba123c 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -555,5 +555,5 @@ if __name__ == "__main__": conn.close() if asan: tdDnodes.StopAllSigint() - tdLog.info("address sanitizer mode finished") + tdLog.info("Address sanitizer mode finished") sys.exit(0) diff --git a/tests/system-test/test.sh b/tests/system-test/test.sh index c6238d37d0..6fbc9961d6 100755 --- a/tests/system-test/test.sh +++ b/tests/system-test/test.sh @@ -45,13 +45,11 @@ declare -x SIM_DIR=$TOP_DIR/sim PROGRAM=$BUILD_DIR/build/bin/tsim PRG_DIR=$SIM_DIR/tsim ASAN_DIR=$SIM_DIR/asan -SYSTEM_TEST_DIR=$CODE_DIR/tests/system-test chmod -R 777 $PRG_DIR echo "------------------------------------------------------------------------" echo "Start TDengine Testing Case ..." echo "BUILD_DIR: $BUILD_DIR" -echo "SYSTEM_TEST_DIR : $SYSTEM_TEST_DIR" echo "SIM_DIR : $SIM_DIR" echo "CODE_DIR : $CODE_DIR" echo "ASAN_DIR : $ASAN_DIR" @@ -61,24 +59,36 @@ rm -rf $SIM_DIR/* mkdir -p $PRG_DIR mkdir -p $ASAN_DIR -cd $SYSTEM_TEST_DIR +cd $CODE_DIR ulimit -n 600000 ulimit -c unlimited #sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e echo "ExcuteCmd:" $* -echo "AsanDir:" $ASAN_DIR/psim.info +AsanFile=$ASAN_DIR/psim.asan +echo "AsanFile:" $AsanFile export LD_PRELOAD=libasan.so.5 -$* -a 2> $ASAN_DIR/psim.info - -result=$? -echo "Execute result:" $result - -if [ $result -eq 0 ]; then - $CODE_DIR/tests/script/sh/checkAsan.sh +$* -a 2> $AsanFile + +export LD_PRELOAD= +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 else + echo "Execute script failure" exit 1 fi -- GitLab