From 0c69fff849b2c19c1d06ad769c3d979532728180 Mon Sep 17 00:00:00 2001 From: freemine Date: Fri, 27 Dec 2024 17:09:40 +0800 Subject: [PATCH] fix ps/grep/kill flaws found in test.script --- tests/script/sh/stop_dnodes.sh | 9 +++++---- tests/script/test.sh | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh index 8923804547..6f647cd5c0 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -13,7 +13,7 @@ if [ -n "$PID" ]; then systemctl stop taosd fi -PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` +PID=`ps -C taosd | grep -w "[t]aosd" | awk '{print $1}' | head -n 1` while [ -n "$PID" ]; do echo kill -9 $PID #pkill -9 taosd @@ -27,7 +27,7 @@ while [ -n "$PID" ]; do PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` done -PID=`ps -ef|grep -w taos | grep -v grep | grep -v taosanode|awk '{print $2}'` +PID=`ps -C taos | grep -w "[t]aos" | awk '{print $1}' | head -n 1` while [ -n "$PID" ]; do echo kill -9 $PID #pkill -9 taos @@ -39,9 +39,10 @@ while [ -n "$PID" ]; do lsof -nti:6030 | xargs kill -9 fi PID=`ps -ef|grep -w taos | grep -v grep | awk '{print $2}'` + PID=`ps -C taos | grep -w "[t]aos" | awk '{print $1}'` done -PID=`ps -ef|grep -w tmq_sim | grep -v grep | awk '{print $2}'` +PID=`ps -C tmq_sim | grep -w "[t]mq_sim" | awk '{print $1}' | head -n 1` while [ -n "$PID" ]; do echo kill -9 $PID #pkill -9 tmq_sim @@ -53,4 +54,4 @@ while [ -n "$PID" ]; do lsof -nti:6030 | xargs kill -9 fi PID=`ps -ef|grep -w tmq_sim | grep -v grep | awk '{print $2}'` -done \ No newline at end of file +done diff --git a/tests/script/test.sh b/tests/script/test.sh index 26c01a6c09..b1588ac2e6 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -43,9 +43,9 @@ CODE_DIR=`pwd` IN_TDINTERNAL="community" if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then - cd ../../.. + pushd ../../.. else - cd ../../ + pushd ../../ fi TOP_DIR=`pwd` @@ -119,6 +119,8 @@ ulimit -c unlimited #sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e +popd + if [ -n "$FILE_NAME" ]; then echo "------------------------------------------------------------------------" if [ $VALGRIND -eq 1 ]; then