From f4ab396574c7842ccbb366e95f8445e44e2b5f0f Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 30 Dec 2021 11:26:42 +0800 Subject: [PATCH] selftest: run-test.sh: wait for subprocess instead of kill it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run tests with 2 VMs, for example nfs/ssh kdump tests, client VM will do the crash and dump, server VM will do vmcore saving and if-vmcore-exists check. Previously, when client VM finishes running, run-test.sh will kill the lead background process, and then check if server VM has outputted "TEST PASSED" or "TEST FAILED" string. However it didn't wait for server VM to finish. As a result, the server VM's final outputs are not collected and checked, leaving the test result as "TEST RESULT NOT FOUND" sometimes. For example, the following is the pstree status of $(jobs -p) before it gets killed. We can see the server VM is still running: run-test.sh,172455 /root/kexec-tools/tests/scripts/run-test.sh --console nfs-early-kdump └─run-test.sh,172457 /root/kexec-tools/tests/scripts/run-test.sh --console... └─timeout,172480 --foreground 10m /root/kexec-tools/tests/scripts/run-qemu... └─qemu-system-x86,172481 -enable-kvm -cpu host -nodefaults... ├─{qemu-system-x86},172489 ├─{qemu-system-x86},172492 ├─{qemu-system-x86},172493 ├─{qemu-system-x86},172628 └─{qemu-system-x86},172629 In this patch, we will wait for $(jobs -p) to finish, in order to get the complete output of test results. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- tests/scripts/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index c3e94a3..1501db4 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -140,7 +140,7 @@ for test_case in $testcases; do if [ $console -eq 1 ]; then run_test_sync $script | tee $(get_test_console_file $script) - [ -n "$(jobs -p)" ] && kill $(jobs -p) + [ -n "$(jobs -p)" ] && wait $(jobs -p) else $(run_test_sync $script > $(get_test_console_file $script)) & watch_test_outputs $test_outputs