diff mbox

[v2,1/8] tests: Run test-wrap-argv with REGENERATE_OUTPUT

Message ID d60ae96710e5cbbe19d58fc9d08d7ab7ed8f3371.1453489454.git.crobinso@redhat.com
State Superseded
Headers show

Commit Message

Cole Robinson Jan. 22, 2016, 7:09 p.m. UTC
To get properly wrapped output
---
 tests/testutils.c | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/tests/testutils.c b/tests/testutils.c
index b587f83..10c26648 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -433,6 +433,32 @@  virtTestCaptureProgramOutput(const char *const argv[] ATTRIBUTE_UNUSED,
 }
 #endif /* !WIN32 */
 
+static int
+virTestRewrapFile(const char *filename)
+{
+    int ret = -1;
+    char *outbuf = NULL;
+    char *script = NULL;
+    virCommandPtr cmd = NULL;
+
+    if (virAsprintf(&script, "%s/test-wrap-argv.pl", abs_srcdir) < 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;
+ cleanup:
+    VIR_FREE(script);
+    virCommandFree(cmd);
+    VIR_FREE(outbuf);
+    return ret;
+}
 
 /**
  * @param stream: output stream to write differences to
@@ -470,17 +496,15 @@  virtTestDifferenceFullInternal(FILE *stream,
     actualEnd = actual + (strlen(actual)-1);
 
     if (expectName && regenerate && (virTestGetRegenerate() > 0)) {
-        char *regencontent;
-
-        /* Try to properly indent qemu argv files */
-        if (!(regencontent = virStringReplace(actual, " -", " \\\n-")))
+        if (virFileWriteStr(expectName, actual, 0666) < 0) {
+            virDispatchError(NULL);
             return -1;
+        }
 
-        if (virFileWriteStr(expectName, regencontent, 0666) < 0) {
-            VIR_FREE(regencontent);
+        if (virTestRewrapFile(expectName) < 0) {
+            virDispatchError(NULL);
             return -1;
         }
-        VIR_FREE(regencontent);
     }
 
     if (!virTestGetDebug())