Skip to content

Commit

Permalink
tests: send error_report to test log
Browse files Browse the repository at this point in the history
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>
Message-Id: <1477326663-67817-3-git-send-email-pbonzini@redhat.com>
  • Loading branch information
bonzini committed Nov 1, 2016
1 parent 397d30e commit 28017e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/glib-compat.h
Expand Up @@ -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
8 changes: 7 additions & 1 deletion stubs/error-printf.c
Expand Up @@ -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)
Expand Down

0 comments on commit 28017e0

Please sign in to comment.