aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2018-07-18 09:34:47 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2018-07-24 17:35:23 +0100
commit977a7204ab69a3591c4c6ed698abb8a6ee673679 (patch)
tree246a65070871bd882aa843db3d1021cea8e09e8c
parentdbddad702630bc2d8dd20f6d0d8076ccb8831a7f (diff)
downloadqemu-977a7204ab69a3591c4c6ed698abb8a6ee673679.zip
qemu-977a7204ab69a3591c4c6ed698abb8a6ee673679.tar.gz
qemu-977a7204ab69a3591c4c6ed698abb8a6ee673679.tar.bz2
tests: don't silence error reporting for all tests
The test-vmstate test is a bit chatty because it triggers various expected failure scenarios and the code in question uses error_report instead of accepting 'Error **errp' parameters. To silence this test the stubs for error_vprintf() were changed to send errors via g_test_message() instead of stderr: commit 28017e010ddf6849cfa830e898da3e44e6610952 Author: Paolo Bonzini <pbonzini@redhat.com> Date: Mon Oct 24 18:31:03 2016 +0200 tests: send error_report to test log Implement error_vprintf to send the output of error_report to the test log. This silences test-vmstate. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1477326663-67817-3-git-send-email-pbonzini@redhat.com> Unfortunately this change has global impact across the entire test suite and means that when tests fail for unexpected reasons, the message is not displayed on stderr. eg when using &error_abort in a call the test merely prints Unexpected error in qcrypto_tls_session_check_certificate() at crypto/tlssession.c:280: and the actual error message is hidden, making it impossible to diagnose the failure. This is especially problematic in CI or build systems where it isn't possible to easily pass the --debug-log flag to tests and re-run with the test log visible. This change makes the previous big hammer much more nuanced, providing a flag in the stub error_vprintf() that can used on a per-test basis to silence the errors. Only the test-vmstate silences errors initially. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r--stubs/error-printf.c3
-rw-r--r--tests/test-vmstate.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/stubs/error-printf.c b/stubs/error-printf.c
index ac6b92a..99c6406 100644
--- a/stubs/error-printf.c
+++ b/stubs/error-printf.c
@@ -4,7 +4,8 @@
void error_vprintf(const char *fmt, va_list ap)
{
- if (g_test_initialized() && !g_test_subprocess()) {
+ if (g_test_initialized() && !g_test_subprocess() &&
+ getenv("QTEST_SILENT_ERRORS")) {
char *msg = g_strdup_vprintf(fmt, ap);
g_test_message("%s", msg);
g_free(msg);
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 087844b..37a7a93 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -859,6 +859,8 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
+ setenv("QTEST_SILENT_ERRORS", "1", 1);
+
g_test_init(&argc, &argv, NULL);
g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);