diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a43859ebfa777efcbf02486d7e7a599584cff687..a9a02d838028f0feb9688af0f93773a539cfc180 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -438,11 +438,11 @@ ,,,system-test,python3 ./test.py -f 1-insert/database_pre_suf.py ,,,system-test,python3 ./test.py -f 1-insert/InsertFuturets.py ,,,system-test,python3 ./test.py -f 0-others/show.py -,,,system-test,python3 ./test.py -f 2-query/abs.py +,,,system-test,./pytest.sh python3 ./test.py -f 2-query/abs.py ,,,system-test,python3 ./test.py -f 2-query/abs.py -R ,,,system-test,python3 ./test.py -f 2-query/and_or_for_byte.py ,,,system-test,python3 ./test.py -f 2-query/and_or_for_byte.py -R -,,,system-test,python3 ./test.py -f 2-query/apercentile.py +,,,system-test,./pytest.sh python3 ./test.py -f 2-query/apercentile.py ,,,system-test,python3 ./test.py -f 2-query/apercentile.py -R ,,,system-test,python3 ./test.py -f 2-query/arccos.py ,,,system-test,python3 ./test.py -f 2-query/arccos.py -R diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index edb3d761cb9f1af2266f5210997ae20fe3cad265..22e612797328440812d22b9795c6ad74f7e3b5c0 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -162,7 +162,11 @@ class TDDnode: def setAsan(self, value): self.asan = value if value: - self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh") + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + self.execPath = os.path.abspath(self.path + "/community/tests/script/sh/exec.sh") + else: + self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh") def getDataSize(self): totalSize = 0 @@ -670,8 +674,13 @@ class TDDnodes: def setAsan(self, value): self.asan = value if value: - self.stopDnodesPath = os.path.abspath(self.path + "/tests/script/sh/stop_dnodes.sh") - self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh") + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + self.stopDnodesPath = os.path.abspath(self.path + "/community/tests/script/sh/stop_dnodes.sh") + self.stopDnodesSigintPath = os.path.abspath(self.path + "/community/tests/script/sh/sigint_stop_dnodes.sh") + else: + self.stopDnodesPath = os.path.abspath(self.path + "/tests/script/sh/stop_dnodes.sh") + self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh") tdLog.info("run in address sanitizer mode") def setKillValgrind(self, value): diff --git a/tests/pytest/util/log.py b/tests/pytest/util/log.py index a132178308302e1dd9997f8dab20f37ac83525b5..000c907ea453fd4e9fea92280788fe8c59328393 100644 --- a/tests/pytest/util/log.py +++ b/tests/pytest/util/log.py @@ -33,7 +33,7 @@ class TDLog: print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err)) def success(self, info): - print("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info)) + printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info)) def notice(self, err): print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err)) diff --git a/tests/script/sh/checkAsan.sh b/tests/script/sh/checkAsan.sh index 0ce74a989e632fc69d4c4fae4a76a1b6bb18959a..8759db87228d0464aa4f2ba467f1c00b861f5863 100755 --- a/tests/script/sh/checkAsan.sh +++ b/tests/script/sh/checkAsan.sh @@ -3,6 +3,7 @@ set +e #set -x +unset LD_PRELOAD SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` @@ -21,19 +22,24 @@ error_num=`cat ${LOG_DIR}/*.asan | grep "ERROR" | wc -l` memory_leak=`cat ${LOG_DIR}/*.asan | grep "Direct leak" | wc -l` indirect_leak=`cat ${LOG_DIR}/*.asan | grep "Indirect leak" | wc -l` runtime_error=`cat ${LOG_DIR}/*.asan | grep "runtime error" | grep -v "trees.c:873" | wc -l` +python_error=`cat ${LOG_DIR}/*.info | grep -w "stack" | 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" +echo -e "\033[44;32;1m"asan python error: $python_error"\033[0m" -let "errors=$error_num+$memory_leak+$indirect_leak+$runtime_error" +let "errors=$error_num+$memory_leak+$indirect_leak+$runtime_error+$python_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" + if [ $python_error -ne 0 ]; then + cat ${LOG_DIR}/*.info + fi cat ${LOG_DIR}/*.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 5ef4cca741c8432db57ba35571c2de8fd545f1bf..c8cb121b8a88b618cbd7410e95741091655cef38 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -11,6 +11,7 @@ set +e #set -x +unset LD_PRELOAD UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` diff --git a/tests/script/sh/sigint_stop_dnodes.sh b/tests/script/sh/sigint_stop_dnodes.sh index 12b58225defd4df068fd656600599bfe919faf44..a398e007725a91ac9d639d1c5a6cd637fdecc746 100755 --- a/tests/script/sh/sigint_stop_dnodes.sh +++ b/tests/script/sh/sigint_stop_dnodes.sh @@ -3,7 +3,7 @@ set +e #set -x -export LD_PRELOAD= +unset 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 38667d9b3f858423264b749df812d71c524aeb92..ce2d7144f9d6a21d00329055cb7b6afb7973ac94 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -3,10 +3,10 @@ set +e #set -x +unset 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.sh b/tests/system-test/pytest.sh similarity index 67% rename from tests/system-test/test.sh rename to tests/system-test/pytest.sh index 2a3187e64117b337c27b6dee794a20a66989ca17..3f0305834288993bf5a9d430d65b78f6b46696cc 100755 --- a/tests/system-test/test.sh +++ b/tests/system-test/pytest.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=$TOP_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,23 +59,40 @@ 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.asan - -export LD_PRELOAD=libasan.so.5 -$* -a 2> $ASAN_DIR/psim.asan -result=$? -echo "Execute result:" $result - -if [ $result -eq 0 ]; then - $CODE_DIR/sh/checkAsan.sh +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 +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 diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 712b9689ba31d46d4d4fad4f76404541526b7ac0..cf9aba123cbc2b902dd13152a24cafd53bdbb03d 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)