diff --git a/fs/template/tests/main.sh b/fs/template/tests/main.sh index 631c5116127d0cc8145e5f72d583d637435b505a..4669753f6cac7eec228a87a03be4e05297a8c6f7 100755 --- a/fs/template/tests/main.sh +++ b/fs/template/tests/main.sh @@ -206,9 +206,33 @@ function test_end() { clean_mount } +fg_pid=$$ + +function handle_timeout() { + fail "测试超时" + fs_pid=$(pgrep $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=20 +( + sleep $max_execution_time + handle_timeout +) & +timer_pid=$! +# echo "timer $timer_pid" + function main() { init_tester test_start @@ -216,3 +240,5 @@ function main() { } main + +kill $timer_pid 2>/dev/null