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

[PATCH] qemumigparamstest: Validate output parameters against QMP schema



Ensure that the migration parameters are formatted properly according to
the schema.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 tests/qemumigparamstest.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c
index 0f7809d763..c4fd575401 100644
--- a/tests/qemumigparamstest.c
+++ b/tests/qemumigparamstest.c
@@ -22,8 +22,10 @@
 #include "virjson.h"
 #include "virbuffer.h"
 #include "virxml.h"
+#include "virhash.h"
 #include "testutils.h"
 #include "testutilsqemu.h"
+#include "tests/testutilsqemuschema.h"
 #include "qemumonitortestutils.h"
 #include "qemu/qemu_migration_params.h"
 #define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW
@@ -36,6 +38,7 @@ typedef struct _qemuMigParamsData qemuMigParamsData;
 struct _qemuMigParamsData {
     virDomainXMLOptionPtr xmlopt;
     const char *name;
+    virHashTablePtr qmpschema;
 };


@@ -141,6 +144,7 @@ qemuMigParamsTestJSON(const void *opaque)
     g_autoptr(virJSONValue) paramsOut = NULL;
     g_autoptr(qemuMigrationParams) migParams = NULL;
     g_autofree char *actualJSON = NULL;
+    g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
     int ret = -1;

     replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
@@ -162,6 +166,17 @@ qemuMigParamsTestJSON(const void *opaque)
         !(actualJSON = virJSONValueToString(paramsOut, true)))
         goto cleanup;

+    if (testQEMUSchemaValidateCommand("migrate-set-parameters",
+                                      paramsOut,
+                                      data->qmpschema,
+                                      false,
+                                      false,
+                                      &debug) < 0) {
+        VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
+                         actualJSON, virBufferCurrentContent(&debug));
+        goto cleanup;
+    }
+
     if (virTestCompareToFile(actualJSON, jsonFile) < 0)
         goto cleanup;

@@ -176,6 +191,7 @@ qemuMigParamsTestJSON(const void *opaque)
 static int
 mymain(void)
 {
+    g_autoptr(virHashTable) qmpschema = NULL;
     virQEMUDriver driver;
     int ret = 0;

@@ -184,10 +200,15 @@ mymain(void)

     virEventRegisterDefaultImpl();

+    if (!(qmpschema = testQEMUSchemaLoadLatest("x86_64"))) {
+        VIR_TEST_VERBOSE("failed to load QMP schema");
+        return EXIT_FAILURE;
+    }
+
 #define DO_TEST(name) \
     do { \
         qemuMigParamsData data = { \
-            driver.xmlopt, name \
+            driver.xmlopt, name, qmpschema \
         }; \
         if (virTestRun(name " (xml)", qemuMigParamsTestXML, &data) < 0) \
             ret = -1; \
-- 
2.26.2


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