From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz6hb-0007mf-Bc for qemu-devel@nongnu.org; Tue, 25 Oct 2016 14:44:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz6hY-0001gN-9k for qemu-devel@nongnu.org; Tue, 25 Oct 2016 14:43:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz6hY-0001fn-4T for qemu-devel@nongnu.org; Tue, 25 Oct 2016 14:43:56 -0400 Date: Tue, 25 Oct 2016 19:43:51 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20161025184351.GD3018@work-vm> References: <1477326663-67817-1-git-send-email-pbonzini@redhat.com> <1477326663-67817-3-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1477326663-67817-3-git-send-email-pbonzini@redhat.com> Subject: Re: [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: Paolo Bonzini Cc: qemu-devel@nongnu.org, armbru@redhat.com, pasic@linux.vnet.ibm.com * Paolo Bonzini (pbonzini@redhat.com) wrote: > Implement error_vprintf to send the output of error_report to > the test log. This silences test-vmstate. > > Signed-off-by: Paolo Bonzini I think I'm OK with that, as long as people are happy with them still getting stuff on stderr on older glib's. The advantage over mine is that there's no per-test change. Dave > --- > 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 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK