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(a)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(a)redhat.com>
Jano