Re: [PATCH] tests/qtest/migration-test: Fix the check for a successful run of analyze-migration.py
On Wed, 22 May 2024 11:23:01 +0200, Thomas Huth wrote: > If analyze-migration.py cannot be run or crashes, the error is currently > ignored since the code only checks for nonzero values in case the child > exited properly. For example, if you run the test with a non-existing > Python interpreter, it still succeeds: > > $ PYTHON=wrongpython QTEST_QEMU_BINARY=./qemu-system-x86_64 > tests/qtest/migration-test > ... > # Running /x86_64/migration/analyze-script > # Using machine type: pc-q35-9.1 > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > source,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/src_serial -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -uuid > ---- -accel qtest > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > target,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/dest_serial -incoming tcp:127.0.0.1:0 -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -accel qtest > ** > > ERROR:../../devel/qemu/tests/qtest/migration-test.c:1603:test_analyze_script: > code should not be reached > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > ok 2 /x86_64/migration/analyze-script > ... > > [...] Queued, thanks!
Re: [PATCH] tests/qtest/migration-test: Fix the check for a successful run of analyze-migration.py
On Wed, May 22, 2024 at 11:23:01AM +0200, Thomas Huth wrote: > If analyze-migration.py cannot be run or crashes, the error is currently > ignored since the code only checks for nonzero values in case the child > exited properly. For example, if you run the test with a non-existing > Python interpreter, it still succeeds: > > $ PYTHON=wrongpython QTEST_QEMU_BINARY=./qemu-system-x86_64 > tests/qtest/migration-test > ... > # Running /x86_64/migration/analyze-script > # Using machine type: pc-q35-9.1 > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > source,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/src_serial -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -uuid > ---- -accel qtest > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > target,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/dest_serial -incoming tcp:127.0.0.1:0 -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -accel qtest > ** > > ERROR:../../devel/qemu/tests/qtest/migration-test.c:1603:test_analyze_script: > code should not be reached > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > ok 2 /x86_64/migration/analyze-script > ... > > Let's better fail the test in case the child did not exit properly, too. > > Signed-off-by: Thomas Huth Reviewed-by: Peter Xu -- Peter Xu
Re: [PATCH] tests/qtest/migration-test: Fix the check for a successful run of analyze-migration.py
Thomas Huth writes: > If analyze-migration.py cannot be run or crashes, the error is currently > ignored since the code only checks for nonzero values in case the child > exited properly. For example, if you run the test with a non-existing > Python interpreter, it still succeeds: > > $ PYTHON=wrongpython QTEST_QEMU_BINARY=./qemu-system-x86_64 > tests/qtest/migration-test > ... > # Running /x86_64/migration/analyze-script > # Using machine type: pc-q35-9.1 > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > source,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/src_serial -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -uuid > ---- -accel qtest > # starting QEMU: exec ./qemu-system-x86_64 -qtest > unix:/tmp/qtest-417639.sock -qtest-log /dev/null -chardev > socket,path=/tmp/qtest-417639.qmp,id=char0 -mon chardev=char0,mode=control > -display none -audio none -accel kvm -accel tcg -machine pc-q35-9.1, -name > target,debug-threads=on -m 150M -serial > file:/tmp/migration-test-XPLUN2/dest_serial -incoming tcp:127.0.0.1:0 -drive > if=none,id=d0,file=/tmp/migration-test-XPLUN2/bootsect,format=raw -device > ide-hd,drive=d0,secs=1,cyls=1,heads=1 -accel qtest > ** > > ERROR:../../devel/qemu/tests/qtest/migration-test.c:1603:test_analyze_script: > code should not be reached > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > migration-test: ../../devel/qemu/tests/qtest/libqtest.c:240: > qtest_wait_qemu: Assertion `pid == s->qemu_pid' failed. > ok 2 /x86_64/migration/analyze-script > ... > > Let's better fail the test in case the child did not exit properly, too. > > Signed-off-by: Thomas Huth > --- > tests/qtest/migration-test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c > index 5b4eca2b20..b7e3406471 100644 > --- a/tests/qtest/migration-test.c > +++ b/tests/qtest/migration-test.c > @@ -1604,7 +1604,7 @@ static void test_analyze_script(void) > } > > g_assert(waitpid(pid, &wstatus, 0) == pid); > -if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0) { > +if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) { > g_test_message("Failed to analyze the migration stream"); > g_test_fail(); > } Reviewed-by: Fabiano Rosas