[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] tests: send error_report to test log
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 2/2] tests: send error_report to test log |
Date: |
Mon, 24 Oct 2016 18:31:03 +0200 |
Implement error_vprintf to send the output of error_report to
the test log. This silences test-vmstate.
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/glib-compat.h | 13 +++++++++++++
stubs/error-printf.c | 8 +++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 8093163..9f86dc8 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -304,4 +304,17 @@ static inline void g_slist_free_full(GSList *list,
GDestroyNotify free_func)
}
#endif
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+/* Always fail. This will not include error_report output in the test log,
+ * sending it instead to stderr.
+ */
+#define g_test_initialized() (0)
+#endif
+#if !GLIB_CHECK_VERSION(2, 38, 0)
+#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
+#error schizophrenic detection of glib subprocess testing
+#endif
+#define g_test_subprocess() (0)
+#endif
+
#endif
diff --git a/stubs/error-printf.c b/stubs/error-printf.c
index 56379e6..ac6b92a 100644
--- a/stubs/error-printf.c
+++ b/stubs/error-printf.c
@@ -4,7 +4,13 @@
void error_vprintf(const char *fmt, va_list ap)
{
- vfprintf(stderr, fmt, ap);
+ if (g_test_initialized() && !g_test_subprocess()) {
+ char *msg = g_strdup_vprintf(fmt, ap);
+ g_test_message("%s", msg);
+ g_free(msg);
+ } else {
+ vfprintf(stderr, fmt, ap);
+ }
}
void error_vprintf_unless_qmp(const char *fmt, va_list ap)
--
1.8.3.1