@samitouri / QOSamiQemu / commits / db0c5927bc

tests/qtest/dbus-vmstate: Honor QTEST_LOG env variable

Don't hide QEMU error messages unconditionally, make the tests that expect to fail honor QTEST_LOG and show every output if the variable is set. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260429190550.20122-4-farosas@suse.de>

Fabiano Rosas committed Apr 29, 2026 at 16:05 UTC db0c5927bc9e7e8cdaa4932a28d8493caca45e90
1 file changed +15 -13
tests/qtest/dbus-vmstate-test.c
+15 -13
@@ -324,17 +324,18 @@ test_dbus_vmstate_missing_src(char *name, MigrateCommon *args)
324 {
325 Test test = { .id_list = "idA,idC",
326 .result = MIG_TEST_FAIL };
327 + bool silent = !getenv("QTEST_LOG");
328
329 /* run in subprocess to silence QEMU error reporting */
329 - if (g_test_subprocess()) {
330 - test_dbus_vmstate(&test);
331 - check_not_migrated(&test.srcA, &test.dstA);
332 - check_not_migrated(&test.srcB, &test.dstB);
330 + if (silent && !g_test_subprocess()) {
331 + g_test_trap_subprocess(NULL, 0, 0);
332 + g_test_trap_assert_passed();
333 return;
334 }
335
336 - g_test_trap_subprocess(NULL, 0, 0);
337 - g_test_trap_assert_passed();
336 + test_dbus_vmstate(&test);
337 + check_not_migrated(&test.srcA, &test.dstA);
338 + check_not_migrated(&test.srcB, &test.dstB);
339 }
340
341 static void
@@ -343,18 +344,19 @@ test_dbus_vmstate_missing_dst(char *name, MigrateCommon *args)
344 Test test = { .id_list = "idA,idB",
345 .without_dst_b = true,
346 .result = MIG_TEST_FAIL };
347 + bool silent = !getenv("QTEST_LOG");
348
349 /* run in subprocess to silence QEMU error reporting */
348 - if (g_test_subprocess()) {
349 - test_dbus_vmstate(&test);
350 - assert(test.srcA.save_called);
351 - assert(test.srcB.save_called);
352 - assert(!test.dstB.save_called);
350 + if (silent && !g_test_subprocess()) {
351 + g_test_trap_subprocess(NULL, 0, 0);
352 + g_test_trap_assert_passed();
353 return;
354 }
355
356 - g_test_trap_subprocess(NULL, 0, 0);
357 - g_test_trap_assert_passed();
356 + test_dbus_vmstate(&test);
357 + assert(test.srcA.save_called);
358 + assert(test.srcB.save_called);
359 + assert(!test.dstB.save_called);
360 }
361
362 static void log_func(const gchar *log_domain, GLogLevelFlags log_level,