未验证 提交 dfa88ea4 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #18285 from taosdata/fix/TD-20530

test: python asan
...@@ -438,11 +438,11 @@ ...@@ -438,11 +438,11 @@
,,,system-test,python3 ./test.py -f 1-insert/database_pre_suf.py ,,,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 1-insert/InsertFuturets.py
,,,system-test,python3 ./test.py -f 0-others/show.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/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
,,,system-test,python3 ./test.py -f 2-query/and_or_for_byte.py -R ,,,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/apercentile.py -R
,,,system-test,python3 ./test.py -f 2-query/arccos.py ,,,system-test,python3 ./test.py -f 2-query/arccos.py
,,,system-test,python3 ./test.py -f 2-query/arccos.py -R ,,,system-test,python3 ./test.py -f 2-query/arccos.py -R
......
...@@ -162,7 +162,11 @@ class TDDnode: ...@@ -162,7 +162,11 @@ class TDDnode:
def setAsan(self, value): def setAsan(self, value):
self.asan = value self.asan = value
if 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): def getDataSize(self):
totalSize = 0 totalSize = 0
...@@ -670,8 +674,13 @@ class TDDnodes: ...@@ -670,8 +674,13 @@ class TDDnodes:
def setAsan(self, value): def setAsan(self, value):
self.asan = value self.asan = value
if value: if value:
self.stopDnodesPath = os.path.abspath(self.path + "/tests/script/sh/stop_dnodes.sh") selfPath = os.path.dirname(os.path.realpath(__file__))
self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh") 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") tdLog.info("run in address sanitizer mode")
def setKillValgrind(self, value): def setKillValgrind(self, value):
......
...@@ -33,7 +33,7 @@ class TDLog: ...@@ -33,7 +33,7 @@ class TDLog:
print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err)) print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
def success(self, info): 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): def notice(self, err):
print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err)) print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
set +e set +e
#set -x #set -x
unset LD_PRELOAD
SCRIPT_DIR=`dirname $0` SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../ cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd` SCRIPT_DIR=`pwd`
...@@ -21,19 +22,24 @@ error_num=`cat ${LOG_DIR}/*.asan | grep "ERROR" | wc -l` ...@@ -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` memory_leak=`cat ${LOG_DIR}/*.asan | grep "Direct leak" | wc -l`
indirect_leak=`cat ${LOG_DIR}/*.asan | grep "Indirect 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` 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 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 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 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 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 if [ $errors -eq 0 ]; then
echo -e "\033[44;32;1m"no asan errors"\033[0m" echo -e "\033[44;32;1m"no asan errors"\033[0m"
exit 0 exit 0
else else
echo -e "\033[44;31;1m"asan total errors: $errors"\033[0m" 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 cat ${LOG_DIR}/*.asan
exit 1 exit 1
fi fi
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
set +e set +e
#set -x #set -x
unset LD_PRELOAD
UNAME_BIN=`which uname` UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN` OS_TYPE=`$UNAME_BIN`
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set +e set +e
#set -x #set -x
export LD_PRELOAD= unset LD_PRELOAD
UNAME_BIN=`which uname` UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN` OS_TYPE=`$UNAME_BIN`
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
set +e set +e
#set -x #set -x
unset LD_PRELOAD
UNAME_BIN=`which uname` UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN` OS_TYPE=`$UNAME_BIN`
export LD_PRELOAD=
PID=`ps -ef|grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` PID=`ps -ef|grep /usr/bin/taosd | grep -v grep | awk '{print $2}'`
if [ -n "$PID" ]; then if [ -n "$PID" ]; then
echo systemctl stop taosd echo systemctl stop taosd
......
...@@ -45,13 +45,11 @@ declare -x SIM_DIR=$TOP_DIR/sim ...@@ -45,13 +45,11 @@ declare -x SIM_DIR=$TOP_DIR/sim
PROGRAM=$BUILD_DIR/build/bin/tsim PROGRAM=$BUILD_DIR/build/bin/tsim
PRG_DIR=$SIM_DIR/tsim PRG_DIR=$SIM_DIR/tsim
ASAN_DIR=$SIM_DIR/asan ASAN_DIR=$SIM_DIR/asan
SYSTEM_TEST_DIR=$TOP_DIR/tests/system-test
chmod -R 777 $PRG_DIR chmod -R 777 $PRG_DIR
echo "------------------------------------------------------------------------" echo "------------------------------------------------------------------------"
echo "Start TDengine Testing Case ..." echo "Start TDengine Testing Case ..."
echo "BUILD_DIR: $BUILD_DIR" echo "BUILD_DIR: $BUILD_DIR"
echo "SYSTEM_TEST_DIR : $SYSTEM_TEST_DIR"
echo "SIM_DIR : $SIM_DIR" echo "SIM_DIR : $SIM_DIR"
echo "CODE_DIR : $CODE_DIR" echo "CODE_DIR : $CODE_DIR"
echo "ASAN_DIR : $ASAN_DIR" echo "ASAN_DIR : $ASAN_DIR"
...@@ -61,23 +59,40 @@ rm -rf $SIM_DIR/* ...@@ -61,23 +59,40 @@ rm -rf $SIM_DIR/*
mkdir -p $PRG_DIR mkdir -p $PRG_DIR
mkdir -p $ASAN_DIR mkdir -p $ASAN_DIR
cd $SYSTEM_TEST_DIR cd $CODE_DIR
ulimit -n 600000 ulimit -n 600000
ulimit -c unlimited ulimit -c unlimited
#sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e #sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e
echo "ExcuteCmd:" $* echo "ExcuteCmd:" $*
echo "AsanDir:" $ASAN_DIR/psim.asan AsanFile=$ASAN_DIR/psim.info
echo "AsanFile:" $AsanFile
export LD_PRELOAD=libasan.so.5
$* -a 2> $ASAN_DIR/psim.asan unset LD_PRELOAD
result=$? #export LD_PRELOAD=libasan.so.5
echo "Execute result:" $result export LD_PRELOAD=`gcc -print-file-name=libasan.so`
echo "Preload AsanSo:" $?
if [ $result -eq 0 ]; then
$CODE_DIR/sh/checkAsan.sh $* -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 else
echo "Execute script failure"
exit 1 exit 1
fi fi
...@@ -555,5 +555,5 @@ if __name__ == "__main__": ...@@ -555,5 +555,5 @@ if __name__ == "__main__":
conn.close() conn.close()
if asan: if asan:
tdDnodes.StopAllSigint() tdDnodes.StopAllSigint()
tdLog.info("address sanitizer mode finished") tdLog.info("Address sanitizer mode finished")
sys.exit(0) sys.exit(0)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册