libvirt/SOURCES/libvirt-testQemuDiskXMLToPr...

107 lines
3.1 KiB
Diff

From 067d165d1ffd968d07ff54c07ccd3bb529d0c130 Mon Sep 17 00:00:00 2001
Message-Id: <067d165d1ffd968d07ff54c07ccd3bb529d0c130@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 24 Mar 2020 16:25:59 +0100
Subject: [PATCH] testQemuDiskXMLToPropsValidateFileSrcOnly: Move together with
rest of xml->json code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The function was misplaced. Group it together with other helper
functions for testing disk XML to qemu JSON props conversion.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit fed97cb435092d9de6f3c862ef297e722f0c0263)
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
Message-Id: <8e84dfd63f90b8b0bf10fe72bb3dcf07af9f6e96.1585063415.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/qemublocktest.c | 61 ++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 40aa1e2825..14c80960b1 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -387,6 +387,37 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque)
}
+static int
+testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
+{
+ struct testQemuDiskXMLToJSONData *data = (void *) opaque;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autofree char *jsonpath = NULL;
+ g_autofree char *actual = NULL;
+ size_t i;
+
+ if (data->fail)
+ return EXIT_AM_SKIP;
+
+ jsonpath = g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSONPath,
+ data->name);
+
+ for (i = 0; i < data->npropssrc; i++) {
+ g_autofree char *jsonstr = NULL;
+
+ if (!(jsonstr = virJSONValueToString(data->propssrc[i], true)))
+ return -1;
+
+ virBufferAdd(&buf, jsonstr, -1);
+ }
+
+ actual = virBufferContentAndReset(&buf);
+
+ return virTestCompareToFile(actual, jsonpath);
+}
+
+
+
struct testQemuImageCreateData {
const char *name;
const char *backingname;
@@ -515,36 +546,6 @@ testQemuImageCreate(const void *opaque)
}
-static int
-testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque)
-{
- struct testQemuDiskXMLToJSONData *data = (void *) opaque;
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- g_autofree char *jsonpath = NULL;
- g_autofree char *actual = NULL;
- size_t i;
-
- if (data->fail)
- return EXIT_AM_SKIP;
-
- jsonpath = g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSONPath,
- data->name);
-
- for (i = 0; i < data->npropssrc; i++) {
- g_autofree char *jsonstr = NULL;
-
- if (!(jsonstr = virJSONValueToString(data->propssrc[i], true)))
- return -1;
-
- virBufferAdd(&buf, jsonstr, -1);
- }
-
- actual = virBufferContentAndReset(&buf);
-
- return virTestCompareToFile(actual, jsonpath);
-}
-
-
static const char *bitmapDetectPrefix = "qemublocktestdata/bitmap/";
static void
--
2.26.0