diff mbox

[1/2] tests/stubs: Add a dummy, silent monitor

Message ID 20161020103636.22228-2-dgilbert@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dr. David Alan Gilbert Oct. 20, 2016, 10:36 a.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

We need an easy way to silence error_report's that come
up in meant-to-fail test cases.  The easiest way to do
that is to create a monitor instance, and since our stubbed
monitor_printf's are slent this causes the errors to disappear.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 stubs/mon-is-qmp.c | 9 +++++++++
 tests/libqtest.h   | 1 +
 2 files changed, 10 insertions(+)

Comments

Eric Blake Oct. 20, 2016, 2:24 p.m. UTC | #1
On 10/20/2016 05:36 AM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> We need an easy way to silence error_report's that come
> up in meant-to-fail test cases.  The easiest way to do
> that is to create a monitor instance, and since our stubbed
> monitor_printf's are slent this causes the errors to disappear.

s/slent/silent/

> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  stubs/mon-is-qmp.c | 9 +++++++++
>  tests/libqtest.h   | 1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
> index a8344ce..012eb28 100644
> --- a/stubs/mon-is-qmp.c
> +++ b/stubs/mon-is-qmp.c
> @@ -2,7 +2,16 @@
>  #include "qemu-common.h"
>  #include "monitor/monitor.h"
>  
> +/* Monitor is defined internally to the real monitor.c, so

s/so/but/

> + * it's real contents are never accessed when stubs are in use;

s/it's/its/  ("it's" is only appropriate if "it is" also works)
diff mbox

Patch

diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
index a8344ce..012eb28 100644
--- a/stubs/mon-is-qmp.c
+++ b/stubs/mon-is-qmp.c
@@ -2,7 +2,16 @@ 
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
+/* Monitor is defined internally to the real monitor.c, so
+ * it's real contents are never accessed when stubs are in use;
+ * just a pointer.
+ */
+struct Monitor {
+    int dummy;
+};
+
 Monitor *cur_mon;
+Monitor stubs_silent_monitor;
 
 bool monitor_cur_is_qmp(void)
 {
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 4be1f77..be34dbb 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -897,4 +897,5 @@  void qmp_fd_send(int fd, const char *fmt, ...);
 QDict *qmp_fdv(int fd, const char *fmt, va_list ap);
 QDict *qmp_fd(int fd, const char *fmt, ...);
 
+extern Monitor stubs_silent_monitor;
 #endif