]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxml2arvtest: Ensure newline at the end of generated .args files
authorPeter Krempa <pkrempa@redhat.com>
Fri, 11 Jun 2021 07:45:12 +0000 (09:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 15 Jun 2021 14:27:35 +0000 (16:27 +0200)
The switch to internal linebreaking of arguments caused a problem when
generating .args files with VIR_TEST_REGENERATE_OUTPUT as the last
argument isn't terminated with a newline.

Switch to using virCommandToStringBuf and append a newline.

Fixes: 0046e0b1c26c8e0167de4a35be2902b9327b0c51
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemuxml2argvtest.c

index 3c5c0fc81b44f1b6a05f71d907ae01620f9e2158..14e24773dc92dc06842afe2c0d672dfd6d428187 100644 (file)
@@ -634,6 +634,7 @@ testCompareXMLToArgv(const void *data)
 {
     struct testQemuInfo *info = (void *) data;
     g_autofree char *migrateURI = NULL;
+    g_auto(virBuffer) actualBuf = VIR_BUFFER_INITIALIZER;
     g_autofree char *actualargv = NULL;
     unsigned int flags = info->flags;
     unsigned int parseFlags = info->parseFlags;
@@ -788,9 +789,12 @@ testCompareXMLToArgv(const void *data)
     if (testCompareXMLToArgvValidateSchema(&driver, migrateURI, info, flags) < 0)
         goto cleanup;
 
-    if (!(actualargv = virCommandToString(cmd, true)))
+    if (virCommandToStringBuf(cmd, &actualBuf, true, false) < 0)
         goto cleanup;
 
+    virBufferAddLit(&actualBuf, "\n");
+    actualargv = virBufferContentAndReset(&actualBuf);
+
     if (virTestCompareToFileFull(actualargv, info->outfile, false) < 0)
         goto cleanup;