From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byi9d-0005mb-PC for qemu-devel@nongnu.org; Mon, 24 Oct 2016 12:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byi9c-0005Ec-VR for qemu-devel@nongnu.org; Mon, 24 Oct 2016 12:31:17 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byi9c-0005E4-Pc for qemu-devel@nongnu.org; Mon, 24 Oct 2016 12:31:16 -0400 Received: by mail-wm0-x243.google.com with SMTP id o81so10582025wma.2 for ; Mon, 24 Oct 2016 09:31:16 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Oct 2016 18:31:03 +0200 Message-Id: <1477326663-67817-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477326663-67817-1-git-send-email-pbonzini@redhat.com> References: <1477326663-67817-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] tests: send error_report to test log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, pasic@linux.vnet.ibm.com, dglibert@redhat.com Implement error_vprintf to send the output of error_report to the test log. This silences test-vmstate. Signed-off-by: Paolo Bonzini --- 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