Re: [PATCH 02/11] tests: qemublock: Add testing of pure disk source specification JSON generator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 04, 2019 at 04:26:26PM +0200, Peter Krempa wrote:
Add testing of the host specification part so that we can be sure that
no image/host specific data will be present.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
@@ -313,6 +341,40 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque)
}


+static int
+testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
+{
+    struct testQemuDiskXMLToJSONData *data = (void *) opaque;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    VIR_AUTOFREE(char *) jsonpath = NULL;
+    VIR_AUTOFREE(char *) actual = NULL;
+    size_t i;
+
+    if (data->fail)
+        return EXIT_AM_SKIP;
+
+    if (virAsprintf(&jsonpath, "%s%s-srconly.json",
+                    testQemuDiskXMLToJSONPath, data->name) < 0)
+        return -1;
+
+    for (i = 0; i < data->npropssrc; i++) {
+        VIR_AUTOFREE(char *) jsonstr = NULL;
+
+        if (!(jsonstr = virJSONValueToString(data->propssrc[i], true)))
+            return -1;

This return skips over the virBufferContentAndReset call below.
Just mark it as AUTOCLEAN even though this is the only code path needing
it.

+
+        virBufferAdd(&buf, jsonstr, -1);
+    }
+
+    if (virBufferCheckError(&buf) < 0)
+        return -1;
+
+    actual = virBufferContentAndReset(&buf);
+
+    return virTestCompareToFile(actual, jsonpath);
+}
+
+
static int
mymain(void)
{

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux