From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bwf-0001Hd-Jj for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bwe-0006Sq-SU for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bwe-0006Si-NM for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:52 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02A4BC05678C for ; Tue, 1 Nov 2016 16:29:52 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA1GThGp005173 for ; Tue, 1 Nov 2016 12:29:51 -0400 From: Paolo Bonzini Date: Tue, 1 Nov 2016 17:29:17 +0100 Message-Id: <1478017783-7703-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> References: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 04/30] tests: send error_report to test log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Implement error_vprintf to send the output of error_report to the test log. This silences test-vmstate. Signed-off-by: Paolo Bonzini Message-Id: <1477326663-67817-3-git-send-email-pbonzini@redhat.com> --- 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 3f8370b..acf254d 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -315,4 +315,17 @@ static inline void g_source_set_name_by_id(guint tag, const char *name) } #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) -- 2.7.4