Browse Source
The current unit tests rely on monitor.o not being linked, such that the monitor stubs get linked instead. Since error_vprintf is in monitor.o this allows a stub error_vprintf impl to be used that calls g_test_message. This takes a different approach, with error_vprintf moving back to error-report.c such that it is always linked into the tests. The monitor_vprintf() stub is then changed to use g_test_message if QTEST_SILENT_ERRORS is set, otherwise it will return -1 and trigger error_vprintf to call vfprintf. The end result is functionally equivalent for the purposes of the unit tests. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>master
5 changed files with 31 additions and 38 deletions
@ -1,18 +0,0 @@ |
|||
#include "qemu/osdep.h" |
|||
#include "qemu/error-report.h" |
|||
#include "monitor/monitor.h" |
|||
|
|||
int error_vprintf(const char *fmt, va_list ap) |
|||
{ |
|||
int ret; |
|||
|
|||
if (g_test_initialized() && !g_test_subprocess() && |
|||
getenv("QTEST_SILENT_ERRORS")) { |
|||
char *msg = g_strdup_vprintf(fmt, ap); |
|||
g_test_message("%s", msg); |
|||
ret = strlen(msg); |
|||
g_free(msg); |
|||
return ret; |
|||
} |
|||
return vfprintf(stderr, fmt, ap); |
|||
} |
|||
Loading…
Reference in new issue