]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorTest: Make check for monitor command match optional
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 19 Sep 2013 13:19:08 +0000 (15:19 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Oct 2013 08:48:47 +0000 (10:48 +0200)
In a few cases we might want to not care if monitor command executed on
the mocked monitor matches the one we have reply for. Sounds crazy, but
if we just want monitor to return certain values (e.g. read from a file)
there is no need to care about command match.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemumonitortestutils.c

index f38cce664121bd896c55ef7207e0514bbc35ddfd..cd43c7baeec2b516b039ccdc25476dab70410035 100644 (file)
@@ -485,7 +485,7 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
         *tmp = '\0';
     }
 
-    if (STRNEQ(data->command_name, cmdname))
+    if (data->command_name && STRNEQ(data->command_name, cmdname))
         ret = qemuMonitorTestAddUnexpectedErrorResponse(test);
     else
         ret = qemuMonitorTestAddReponse(test, data->response);
@@ -604,7 +604,8 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
         goto cleanup;
     }
 
-    if (STRNEQ(data->command_name, cmdname)) {
+    if (data->command_name &&
+        STRNEQ(data->command_name, cmdname)) {
         ret = qemuMonitorTestAddUnexpectedErrorResponse(test);
         goto cleanup;
     }
@@ -612,7 +613,7 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
     if (!(args = virJSONValueObjectGet(val, "arguments"))) {
         ret = qemuMonitorReportError(test,
                                      "Missing arguments section for command '%s'",
-                                     data->command_name);
+                                     NULLSTR(data->command_name));
         goto cleanup;
     }
 
@@ -622,7 +623,8 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
         if (!(argobj = virJSONValueObjectGet(args, arg->argname))) {
             ret = qemuMonitorReportError(test,
                                          "Missing argument '%s' for command '%s'",
-                                         arg->argname, data->command_name);
+                                         arg->argname,
+                                         NULLSTR(data->command_name));
             goto cleanup;
         }
 
@@ -636,7 +638,8 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
                                          "Invalid value of argument '%s' "
                                          "of command '%s': "
                                          "expected '%s' got '%s'",
-                                         arg->argname, data->command_name,
+                                         arg->argname,
+                                         NULLSTR(data->command_name),
                                          arg->argval, argstr);
             goto cleanup;
         }