mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c501663a71
commit
8098462bfb
@ -22,8 +22,10 @@
|
|||||||
#include "virjson.h"
|
#include "virjson.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
|
#include "virhash.h"
|
||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
#include "testutilsqemu.h"
|
#include "testutilsqemu.h"
|
||||||
|
#include "tests/testutilsqemuschema.h"
|
||||||
#include "qemumonitortestutils.h"
|
#include "qemumonitortestutils.h"
|
||||||
#include "qemu/qemu_migration_params.h"
|
#include "qemu/qemu_migration_params.h"
|
||||||
#define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW
|
#define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW
|
||||||
@ -36,6 +38,7 @@ typedef struct _qemuMigParamsData qemuMigParamsData;
|
|||||||
struct _qemuMigParamsData {
|
struct _qemuMigParamsData {
|
||||||
virDomainXMLOptionPtr xmlopt;
|
virDomainXMLOptionPtr xmlopt;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
virHashTablePtr qmpschema;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -141,6 +144,7 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
g_autoptr(virJSONValue) paramsOut = NULL;
|
g_autoptr(virJSONValue) paramsOut = NULL;
|
||||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||||
g_autofree char *actualJSON = NULL;
|
g_autofree char *actualJSON = NULL;
|
||||||
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
||||||
@ -162,6 +166,17 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
!(actualJSON = virJSONValueToString(paramsOut, true)))
|
!(actualJSON = virJSONValueToString(paramsOut, true)))
|
||||||
goto cleanup;
|
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)
|
if (virTestCompareToFile(actualJSON, jsonFile) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -176,6 +191,7 @@ qemuMigParamsTestJSON(const void *opaque)
|
|||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
|
g_autoptr(virHashTable) qmpschema = NULL;
|
||||||
virQEMUDriver driver;
|
virQEMUDriver driver;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -184,10 +200,15 @@ mymain(void)
|
|||||||
|
|
||||||
virEventRegisterDefaultImpl();
|
virEventRegisterDefaultImpl();
|
||||||
|
|
||||||
|
if (!(qmpschema = testQEMUSchemaLoadLatest("x86_64"))) {
|
||||||
|
VIR_TEST_VERBOSE("failed to load QMP schema");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
#define DO_TEST(name) \
|
#define DO_TEST(name) \
|
||||||
do { \
|
do { \
|
||||||
qemuMigParamsData data = { \
|
qemuMigParamsData data = { \
|
||||||
driver.xmlopt, name \
|
driver.xmlopt, name, qmpschema \
|
||||||
}; \
|
}; \
|
||||||
if (virTestRun(name " (xml)", qemuMigParamsTestXML, &data) < 0) \
|
if (virTestRun(name " (xml)", qemuMigParamsTestXML, &data) < 0) \
|
||||||
ret = -1; \
|
ret = -1; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user