[libvirt] [PATCH] tests: Fix VIR_TEST_REGENERATE_OUTPUT

Cole Robinson crobinso at redhat.com
Tue Apr 12 22:33:57 UTC 2016


commit 950a90d489 mocked some virCommand handling for the qemu tests,
but we were using that in the test suite to call test-wrap-argv.pl for
regenerating test output.

Switch the generator code to just use system() instead
---
 tests/testutils.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index a0ce4b6..4f3e67b 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -434,24 +434,15 @@ virTestRewrapFile(const char *filename)
 {
     int ret = -1;
     char *outbuf = NULL;
-    char *script = NULL;
-    virCommandPtr cmd = NULL;
+    char *cmd = NULL;
 
-    if (virAsprintf(&script, "%s/test-wrap-argv.pl", abs_srcdir) < 0)
+    if (virAsprintf(&cmd, "echo \"$(%s/test-wrap-argv.pl %s)\" > %s",
+                    abs_srcdir, filename, filename) < 0)
         goto cleanup;
 
-    cmd = virCommandNewArgList(script, filename, NULL);
-    virCommandSetOutputBuffer(cmd, &outbuf);
-    if (virCommandRun(cmd, NULL) < 0)
-        goto cleanup;
-
-    if (virFileWriteStr(filename, outbuf, 0666) < 0)
-        goto cleanup;
-
-    ret = 0;
+    ret = system(cmd);
  cleanup:
-    VIR_FREE(script);
-    virCommandFree(cmd);
+    VIR_FREE(cmd);
     VIR_FREE(outbuf);
     return ret;
 }
-- 
2.7.3




More information about the libvir-list mailing list