From 42417d5e89272edcd5dbb974992b03742cc9388b Mon Sep 17 00:00:00 2001 From: BillyOu <12047406+billyou@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 12:18:59 +0000 Subject: [PATCH] =?UTF-8?q?update=20fs/template/tests/main.sh.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B6=85=E6=97=B6=E6=A3=80=E6=B5=8B=EF=BC=8C=E5=BB=B6?= =?UTF-8?q?=E9=95=BF=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=EF=BC=8C=E5=9B=A0?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E7=BB=88=E6=AD=A2=E6=97=B6=E5=8F=AAkill?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E7=9A=84=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BillyOu <12047406+billyou@user.noreply.gitee.com> --- fs/template/tests/main.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/fs/template/tests/main.sh b/fs/template/tests/main.sh index 631c511..4735420 100755 --- a/fs/template/tests/main.sh +++ b/fs/template/tests/main.sh @@ -206,13 +206,39 @@ function test_end() { clean_mount } +fg_pid=$$ + +function handle_timeout() { + fail "测试超时" + fs_pid=$(pgrep -u $USER $PROJECT_NAME) + if [ ! -z "$fs_pid" ]; then + for PID in $fs_pid; do + # echo "kill $PID" + kill -9 $PID + done + fi + fusermount -u $MNTPOINT + kill -9 $fg_pid + exit 1 +} + # Main echo "测试脚本工程根目录: $ROOT_PATH" +max_execution_time=100 +( + sleep $max_execution_time + handle_timeout +) & +timer_pid=$! +# echo "timer $timer_pid" + function main() { init_tester - test_start + test_start test_end } main + +kill $timer_pid 2>/dev/null -- Gitee