mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 13:17:51 +03:00
tests: qemu: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
51be622d76
commit
d43f393134
@ -141,7 +141,6 @@ testQemuCaps(const void *opaque)
|
|||||||
static int
|
static int
|
||||||
testQemuCapsCopy(const void *opaque)
|
testQemuCapsCopy(const void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const testQemuData *data = opaque;
|
const testQemuData *data = opaque;
|
||||||
g_autofree char *capsFile = NULL;
|
g_autofree char *capsFile = NULL;
|
||||||
g_autoptr(virQEMUCaps) orig = NULL;
|
g_autoptr(virQEMUCaps) orig = NULL;
|
||||||
@ -154,21 +153,18 @@ testQemuCapsCopy(const void *opaque)
|
|||||||
|
|
||||||
if (!(orig = qemuTestParseCapabilitiesArch(
|
if (!(orig = qemuTestParseCapabilitiesArch(
|
||||||
virArchFromString(data->archName), capsFile)))
|
virArchFromString(data->archName), capsFile)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(copy = virQEMUCapsNewCopy(orig)))
|
if (!(copy = virQEMUCapsNewCopy(orig)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(actual = virQEMUCapsFormatCache(copy)))
|
if (!(actual = virQEMUCapsFormatCache(copy)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actual, capsFile) < 0)
|
if (virTestCompareToFile(actual, capsFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +129,6 @@ testGetCaps(char *capsData, const testQemuData *data)
|
|||||||
static int
|
static int
|
||||||
testQemuCapsXML(const void *opaque)
|
testQemuCapsXML(const void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
const testQemuData *data = opaque;
|
const testQemuData *data = opaque;
|
||||||
g_autofree char *capsFile = NULL;
|
g_autofree char *capsFile = NULL;
|
||||||
g_autofree char *xmlFile = NULL;
|
g_autofree char *xmlFile = NULL;
|
||||||
@ -144,21 +143,19 @@ testQemuCapsXML(const void *opaque)
|
|||||||
data->archName, data->suffix);
|
data->archName, data->suffix);
|
||||||
|
|
||||||
if (virTestLoadFile(capsFile, &capsData) < 0)
|
if (virTestLoadFile(capsFile, &capsData) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(capsProvided = testGetCaps(capsData, data)))
|
if (!(capsProvided = testGetCaps(capsData, data)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
capsXml = virCapabilitiesFormatXML(capsProvided);
|
capsXml = virCapabilitiesFormatXML(capsProvided);
|
||||||
if (!capsXml)
|
if (!capsXml)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(capsXml, xmlFile) < 0)
|
if (virTestCompareToFile(capsXml, xmlFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -34,7 +34,6 @@ testCompareXMLToXMLFiles(const char *inxml,
|
|||||||
g_autofree char *inXmlData = NULL;
|
g_autofree char *inXmlData = NULL;
|
||||||
g_autofree char *outXmlData = NULL;
|
g_autofree char *outXmlData = NULL;
|
||||||
g_autofree char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
int ret = -1;
|
|
||||||
unsigned int parseflags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
|
unsigned int parseflags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
|
||||||
unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
|
unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
|
||||||
bool cur = false;
|
bool cur = false;
|
||||||
@ -49,40 +48,37 @@ testCompareXMLToXMLFiles(const char *inxml,
|
|||||||
parseflags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
parseflags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
||||||
|
|
||||||
if (virTestLoadFile(inxml, &inXmlData) < 0)
|
if (virTestLoadFile(inxml, &inXmlData) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestLoadFile(outxml, &outXmlData) < 0)
|
if (virTestLoadFile(outxml, &outXmlData) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(def = virDomainSnapshotDefParseString(inXmlData,
|
if (!(def = virDomainSnapshotDefParseString(inXmlData,
|
||||||
driver.xmlopt, NULL, &cur,
|
driver.xmlopt, NULL, &cur,
|
||||||
parseflags)))
|
parseflags)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (cur) {
|
if (cur) {
|
||||||
if (!(flags & TEST_INTERNAL))
|
if (!(flags & TEST_INTERNAL))
|
||||||
goto cleanup;
|
return -1;
|
||||||
formatflags |= VIR_DOMAIN_SNAPSHOT_FORMAT_CURRENT;
|
formatflags |= VIR_DOMAIN_SNAPSHOT_FORMAT_CURRENT;
|
||||||
}
|
}
|
||||||
if (flags & TEST_RUNNING) {
|
if (flags & TEST_RUNNING) {
|
||||||
if (def->state)
|
if (def->state)
|
||||||
goto cleanup;
|
return -1;
|
||||||
def->state = VIR_DOMAIN_RUNNING;
|
def->state = VIR_DOMAIN_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(actual = virDomainSnapshotDefFormat(uuid, def,
|
if (!(actual = virDomainSnapshotDefFormat(uuid, def,
|
||||||
driver.xmlopt,
|
driver.xmlopt,
|
||||||
formatflags)))
|
formatflags)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(outXmlData, actual)) {
|
if (STRNEQ(outXmlData, actual)) {
|
||||||
virTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml);
|
virTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testInfo {
|
struct testInfo {
|
||||||
|
@ -472,33 +472,29 @@ testQemuHotplugCpuPrepare(const char *test,
|
|||||||
static int
|
static int
|
||||||
testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data)
|
testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *activeXML = NULL;
|
g_autofree char *activeXML = NULL;
|
||||||
g_autofree char *configXML = NULL;
|
g_autofree char *configXML = NULL;
|
||||||
|
|
||||||
if (data->file_xml_res_live) {
|
if (data->file_xml_res_live) {
|
||||||
if (!(activeXML = virDomainDefFormat(data->vm->def, driver.xmlopt,
|
if (!(activeXML = virDomainDefFormat(data->vm->def, driver.xmlopt,
|
||||||
VIR_DOMAIN_DEF_FORMAT_SECURE)))
|
VIR_DOMAIN_DEF_FORMAT_SECURE)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(activeXML, data->file_xml_res_live) < 0)
|
if (virTestCompareToFile(activeXML, data->file_xml_res_live) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->file_xml_res_conf) {
|
if (data->file_xml_res_conf) {
|
||||||
if (!(configXML = virDomainDefFormat(data->vm->newDef, driver.xmlopt,
|
if (!(configXML = virDomainDefFormat(data->vm->newDef, driver.xmlopt,
|
||||||
VIR_DOMAIN_DEF_FORMAT_SECURE |
|
VIR_DOMAIN_DEF_FORMAT_SECURE |
|
||||||
VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
|
VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(configXML, data->file_xml_res_conf) < 0)
|
if (virTestCompareToFile(configXML, data->file_xml_res_conf) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,21 +32,16 @@ testCompareMemLock(const void *data)
|
|||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
g_autofree char *xml = NULL;
|
g_autofree char *xml = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
xml = g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml", abs_srcdir,
|
xml = g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml", abs_srcdir,
|
||||||
info->name);
|
info->name);
|
||||||
|
|
||||||
if (!(def = virDomainDefParseFile(xml, driver.xmlopt, NULL,
|
if (!(def = virDomainDefParseFile(xml, driver.xmlopt, NULL,
|
||||||
VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
|
VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def, false));
|
return virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def, false));
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||||
|
@ -64,29 +64,25 @@ qemuMigParamsTestXML2XML(const void *opaque)
|
|||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||||
g_autofree char *actualXML = NULL;
|
g_autofree char *actualXML = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml", abs_srcdir,
|
xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml", abs_srcdir,
|
||||||
data->name);
|
data->name);
|
||||||
|
|
||||||
if (!(doc = virXMLParseFileCtxt(xmlFile, &ctxt)))
|
if (!(doc = virXMLParseFileCtxt(xmlFile, &ctxt)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMigrationParamsParse(ctxt, &migParams) < 0)
|
if (qemuMigrationParamsParse(ctxt, &migParams) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuMigParamsTestFormatXML(&buf, migParams);
|
qemuMigParamsTestFormatXML(&buf, migParams);
|
||||||
|
|
||||||
if (!(actualXML = virBufferContentAndReset(&buf)))
|
if (!(actualXML = virBufferContentAndReset(&buf)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actualXML, xmlFile) < 0)
|
if (virTestCompareToFile(actualXML, xmlFile) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -787,26 +787,25 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
|||||||
virJSONValuePtr argobj;
|
virJSONValuePtr argobj;
|
||||||
const char *cmdname;
|
const char *cmdname;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(val = virJSONValueFromString(cmdstr)))
|
if (!(val = virJSONValueFromString(cmdstr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
||||||
qemuMonitorTestError("Missing command name in %s", cmdstr);
|
qemuMonitorTestError("Missing command name in %s", cmdstr);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->command_name &&
|
if (data->command_name &&
|
||||||
STRNEQ(data->command_name, cmdname)) {
|
STRNEQ(data->command_name, cmdname)) {
|
||||||
qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
|
qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(args = virJSONValueObjectGet(val, "arguments"))) {
|
if (!(args = virJSONValueObjectGet(val, "arguments"))) {
|
||||||
qemuMonitorTestError("Missing arguments section for command '%s'",
|
qemuMonitorTestError("Missing arguments section for command '%s'",
|
||||||
NULLSTR(data->command_name));
|
NULLSTR(data->command_name));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* validate the args */
|
/* validate the args */
|
||||||
@ -818,12 +817,12 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
|||||||
qemuMonitorTestError("Missing argument '%s' for command '%s'",
|
qemuMonitorTestError("Missing argument '%s' for command '%s'",
|
||||||
arg->argname,
|
arg->argname,
|
||||||
NULLSTR(data->command_name));
|
NULLSTR(data->command_name));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert the argument to string */
|
/* convert the argument to string */
|
||||||
if (!(argstr = virJSONValueToString(argobj, false)))
|
if (!(argstr = virJSONValueToString(argobj, false)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* verify that the argument value is expected */
|
/* verify that the argument value is expected */
|
||||||
if (STRNEQ(argstr, arg->argval)) {
|
if (STRNEQ(argstr, arg->argval)) {
|
||||||
@ -832,15 +831,12 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
|
|||||||
arg->argname,
|
arg->argname,
|
||||||
NULLSTR(data->command_name),
|
NULLSTR(data->command_name),
|
||||||
arg->argval, argstr);
|
arg->argval, argstr);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* arguments checked out, return the response */
|
/* arguments checked out, return the response */
|
||||||
ret = qemuMonitorTestAddResponse(test, data->response);
|
return qemuMonitorTestAddResponse(test, data->response);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -907,44 +903,40 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
|
|||||||
virJSONValuePtr args;
|
virJSONValuePtr args;
|
||||||
g_autofree char *argstr = NULL;
|
g_autofree char *argstr = NULL;
|
||||||
const char *cmdname;
|
const char *cmdname;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(val = virJSONValueFromString(cmdstr)))
|
if (!(val = virJSONValueFromString(cmdstr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
||||||
qemuMonitorTestError("Missing command name in %s", cmdstr);
|
qemuMonitorTestError("Missing command name in %s", cmdstr);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(data->command_name, cmdname)) {
|
if (STRNEQ(data->command_name, cmdname)) {
|
||||||
qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
|
qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(args = virJSONValueObjectGet(val, "arguments"))) {
|
if (!(args = virJSONValueObjectGet(val, "arguments"))) {
|
||||||
qemuMonitorTestError("Missing arguments section for command '%s'",
|
qemuMonitorTestError("Missing arguments section for command '%s'",
|
||||||
data->command_name);
|
data->command_name);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert the arguments to string */
|
/* convert the arguments to string */
|
||||||
if (!(argstr = virJSONValueToString(args, false)))
|
if (!(argstr = virJSONValueToString(args, false)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* verify that the argument value is expected */
|
/* verify that the argument value is expected */
|
||||||
if (STRNEQ(argstr, data->expectArgs)) {
|
if (STRNEQ(argstr, data->expectArgs)) {
|
||||||
qemuMonitorTestError("%s: expected arguments: '%s', got: '%s'",
|
qemuMonitorTestError("%s: expected arguments: '%s', got: '%s'",
|
||||||
data->command_name,
|
data->command_name,
|
||||||
data->expectArgs, argstr);
|
data->expectArgs, argstr);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* arguments checked out, return the response */
|
/* arguments checked out, return the response */
|
||||||
ret = qemuMonitorTestAddResponse(test, data->response);
|
return qemuMonitorTestAddResponse(test, data->response);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user