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

Ján Tomko jtomko at redhat.com
Mon Jul 8 11:43:33 UTC 2019


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 at redhat.com>
>---
>@@ -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 at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190708/44508673/attachment-0001.sig>


More information about the libvir-list mailing list