qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com, pasic@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 2/2] tests: send error_report to test log
Date: Tue, 25 Oct 2016 19:43:51 +0100	[thread overview]
Message-ID: <20161025184351.GD3018@work-vm> (raw)
In-Reply-To: <1477326663-67817-3-git-send-email-pbonzini@redhat.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 <pbonzini@redhat.com>

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

      parent reply	other threads:[~2016-10-25 18:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 16:31 [Qemu-devel] [PATCH 0/2] tests: silence error_report in tests Paolo Bonzini
2016-10-24 16:31 ` [Qemu-devel] [PATCH 1/2] qemu-error: remove dependency of stubs on monitor Paolo Bonzini
2016-10-24 16:31 ` [Qemu-devel] [PATCH 2/2] tests: send error_report to test log Paolo Bonzini
2016-10-25 11:06   ` Halil Pasic
2016-10-25 11:34     ` Paolo Bonzini
2016-10-26 11:04       ` Halil Pasic
2016-10-25 18:43   ` Dr. David Alan Gilbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161025184351.GD3018@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).