Received: from eggs.gnu.org ([2001:4830:134:3::10]:38038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Dil-0005Ud-JU for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1Dij-0003o0-Gw for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:55 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1Dij-0003nk-AX for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:53 -0400 Received: by mail-wm0-x241.google.com with SMTP id p190so12468707wmp.1 for ; Mon, 31 Oct 2016 07:37:53 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-246-178.clienti.tiscali.it. [78.12.246.178]) by smtp.gmail.com with ESMTPSA id r72sm25166766wmd.21.2016.10.31.07.37.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:37:51 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 31 Oct 2016 15:37:20 +0100 Message-Id: <1477924663-30950-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> References: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 04/27] 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