]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: fix dry run handling in network firewall test
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 1 Nov 2018 11:42:56 +0000 (11:42 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 7 Dec 2018 15:45:51 +0000 (15:45 +0000)
The networkxml2firewalltest sets virCommand to dry run mode but doesn't
provide a callback to fill in stdout/stderr. As a result when the
firewall code queries rules it gets a NULL output and so never triggers
the callback to process output.

This trivial change just returns an empty string for the command output
in order to ensure the callback gets triggered. It has no effect right
now, but in future patches this will trigger greater test coverage.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tests/networkxml2firewalltest.c

index 505ff0c740c394ebfe48e3ba45d26adb85a96cb4..5e3d8906c5d872e01d086cee0832cfb29dad3e05 100644 (file)
@@ -44,6 +44,20 @@ static const char *abs_top_srcdir;
 #  error "test case not ported to this platform"
 # endif
 
+static void
+testCommandDryRun(const char *const*args ATTRIBUTE_UNUSED,
+                  const char *const*env ATTRIBUTE_UNUSED,
+                  const char *input ATTRIBUTE_UNUSED,
+                  char **output,
+                  char **error,
+                  int *status,
+                  void *opaque ATTRIBUTE_UNUSED)
+{
+    *status = 0;
+    ignore_value(VIR_STRDUP_QUIET(*output, ""));
+    ignore_value(VIR_STRDUP_QUIET(*error, ""));
+}
+
 static int testCompareXMLToArgvFiles(const char *xml,
                                      const char *cmdline)
 {
@@ -53,7 +67,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
     virNetworkDefPtr def = NULL;
     int ret = -1;
 
-    virCommandSetDryRun(&buf, NULL, NULL);
+    virCommandSetDryRun(&buf, testCommandDryRun, NULL);
 
     if (!(def = virNetworkDefParseFile(xml)))
         goto cleanup;