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