mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +00:00
tests: qemu: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
d66fb7ac15
commit
2e3b056cdd
@ -58,7 +58,7 @@ int
|
|||||||
qemuMonitorSend(qemuMonitor *mon,
|
qemuMonitorSend(qemuMonitor *mon,
|
||||||
qemuMonitorMessage *msg)
|
qemuMonitorMessage *msg)
|
||||||
{
|
{
|
||||||
char *reformatted;
|
g_autofree char *reformatted = NULL;
|
||||||
|
|
||||||
REAL_SYM(realQemuMonitorSend);
|
REAL_SYM(realQemuMonitorSend);
|
||||||
|
|
||||||
@ -73,7 +73,6 @@ qemuMonitorSend(qemuMonitor *mon,
|
|||||||
printLineSkipEmpty("\n", stdout);
|
printLineSkipEmpty("\n", stdout);
|
||||||
|
|
||||||
printLineSkipEmpty(reformatted, stdout);
|
printLineSkipEmpty(reformatted, stdout);
|
||||||
VIR_FREE(reformatted);
|
|
||||||
|
|
||||||
return realQemuMonitorSend(mon, msg);
|
return realQemuMonitorSend(mon, msg);
|
||||||
}
|
}
|
||||||
@ -89,7 +88,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
|
|||||||
qemuMonitorMessage *msg)
|
qemuMonitorMessage *msg)
|
||||||
{
|
{
|
||||||
virJSONValue *value = NULL;
|
virJSONValue *value = NULL;
|
||||||
char *json = NULL;
|
g_autofree char *json = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
REAL_SYM(realQemuMonitorJSONIOProcessLine);
|
REAL_SYM(realQemuMonitorJSONIOProcessLine);
|
||||||
@ -116,7 +115,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(json);
|
|
||||||
virJSONValueFree(value);
|
virJSONValueFree(value);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ testQemuCommandBuildFromJSON(const void *opaque)
|
|||||||
const testQemuCommandBuildObjectFromJSONData *data = opaque;
|
const testQemuCommandBuildObjectFromJSONData *data = opaque;
|
||||||
virJSONValue *val = NULL;
|
virJSONValue *val = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *result = NULL;
|
g_autofree char *result = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(val = virJSONValueFromString(data->props))) {
|
if (!(val = virJSONValueFromString(data->props))) {
|
||||||
@ -66,7 +66,6 @@ testQemuCommandBuildFromJSON(const void *opaque)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(val);
|
virJSONValueFree(val);
|
||||||
VIR_FREE(result);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,8 +650,8 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct qemuMonitorJSONTestAttachChardevData data = {0};
|
struct qemuMonitorJSONTestAttachChardevData data = {0};
|
||||||
char *jsonreply = NULL;
|
g_autofree char *jsonreply = NULL;
|
||||||
char *fulllabel = NULL;
|
g_autofree char *fulllabel = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!reply)
|
if (!reply)
|
||||||
@ -680,8 +680,6 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMonitorTestFree(data.test);
|
qemuMonitorTestFree(data.test);
|
||||||
VIR_FREE(jsonreply);
|
|
||||||
VIR_FREE(fulllabel);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1723,7 +1721,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *opaque)
|
|||||||
virDomainXMLOption *xmlopt = data->xmlopt;
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuMonitorMigrationStats stats, expectedStats;
|
qemuMonitorMigrationStats stats, expectedStats;
|
||||||
char *error = NULL;
|
g_autofree char *error = NULL;
|
||||||
g_autoptr(qemuMonitorTest) test = NULL;
|
g_autoptr(qemuMonitorTest) test = NULL;
|
||||||
|
|
||||||
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||||
@ -1784,7 +1782,6 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *opaque)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(error);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2162,10 +2159,10 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
|
|||||||
{
|
{
|
||||||
const struct testCPUData *data = opaque;
|
const struct testCPUData *data = opaque;
|
||||||
virCPUData *cpuData = NULL;
|
virCPUData *cpuData = NULL;
|
||||||
char *jsonFile = NULL;
|
g_autofree char *jsonFile = NULL;
|
||||||
char *dataFile = NULL;
|
g_autofree char *dataFile = NULL;
|
||||||
char *jsonStr = NULL;
|
g_autofree char *jsonStr = NULL;
|
||||||
char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autoptr(qemuMonitorTest) test = NULL;
|
g_autoptr(qemuMonitorTest) test = NULL;
|
||||||
|
|
||||||
@ -2211,10 +2208,6 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(jsonFile);
|
|
||||||
VIR_FREE(dataFile);
|
|
||||||
VIR_FREE(jsonStr);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
virCPUDataFree(cpuData);
|
virCPUDataFree(cpuData);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2409,12 +2402,12 @@ testQemuMonitorCPUInfo(const void *opaque)
|
|||||||
{
|
{
|
||||||
const struct testCPUInfoData *data = opaque;
|
const struct testCPUInfoData *data = opaque;
|
||||||
virDomainObj *vm = NULL;
|
virDomainObj *vm = NULL;
|
||||||
char *queryCpusFile = NULL;
|
g_autofree char *queryCpusFile = NULL;
|
||||||
char *queryHotpluggableFile = NULL;
|
g_autofree char *queryHotpluggableFile = NULL;
|
||||||
char *dataFile = NULL;
|
g_autofree char *dataFile = NULL;
|
||||||
char *queryCpusStr = NULL;
|
g_autofree char *queryCpusStr = NULL;
|
||||||
char *queryHotpluggableStr = NULL;
|
g_autofree char *queryHotpluggableStr = NULL;
|
||||||
char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
const char *queryCpusFunction;
|
const char *queryCpusFunction;
|
||||||
qemuMonitorCPUInfo *vcpus = NULL;
|
qemuMonitorCPUInfo *vcpus = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
@ -2468,12 +2461,6 @@ testQemuMonitorCPUInfo(const void *opaque)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(queryCpusFile);
|
|
||||||
VIR_FREE(queryHotpluggableFile);
|
|
||||||
VIR_FREE(dataFile);
|
|
||||||
VIR_FREE(queryCpusStr);
|
|
||||||
VIR_FREE(queryHotpluggableStr);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
qemuMonitorCPUInfoFree(vcpus, data->maxvcpus);
|
qemuMonitorCPUInfoFree(vcpus, data->maxvcpus);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2518,8 +2505,8 @@ testBlockNodeNameDetect(const void *opaque)
|
|||||||
{
|
{
|
||||||
const char *testname = opaque;
|
const char *testname = opaque;
|
||||||
const char *pathprefix = "qemumonitorjsondata/qemumonitorjson-nodename-";
|
const char *pathprefix = "qemumonitorjsondata/qemumonitorjson-nodename-";
|
||||||
char *resultFile = NULL;
|
g_autofree char *resultFile = NULL;
|
||||||
char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
virJSONValue *namedNodesJson = NULL;
|
virJSONValue *namedNodesJson = NULL;
|
||||||
virJSONValue *blockstatsJson = NULL;
|
virJSONValue *blockstatsJson = NULL;
|
||||||
GHashTable *nodedata = NULL;
|
GHashTable *nodedata = NULL;
|
||||||
@ -2553,8 +2540,6 @@ testBlockNodeNameDetect(const void *opaque)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(resultFile);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
virHashFree(nodedata);
|
virHashFree(nodedata);
|
||||||
virJSONValueFree(namedNodesJson);
|
virJSONValueFree(namedNodesJson);
|
||||||
virJSONValueFree(blockstatsJson);
|
virJSONValueFree(blockstatsJson);
|
||||||
@ -2943,7 +2928,7 @@ mymain(void)
|
|||||||
testQemuMonitorJSONSimpleFuncData simpleFunc;
|
testQemuMonitorJSONSimpleFuncData simpleFunc;
|
||||||
struct testQAPISchemaData qapiData;
|
struct testQAPISchemaData qapiData;
|
||||||
virJSONValue *metaschema = NULL;
|
virJSONValue *metaschema = NULL;
|
||||||
char *metaschemastr = NULL;
|
g_autofree char *metaschemastr = NULL;
|
||||||
|
|
||||||
if (qemuTestDriverInit(&driver) < 0)
|
if (qemuTestDriverInit(&driver) < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -3235,7 +3220,6 @@ mymain(void)
|
|||||||
DO_TEST(qemuMonitorJSONGetCPUModelBaseline);
|
DO_TEST(qemuMonitorJSONGetCPUModelBaseline);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(metaschemastr);
|
|
||||||
virJSONValueFree(metaschema);
|
virJSONValueFree(metaschema);
|
||||||
virHashFree(qapiData.schema);
|
virHashFree(qapiData.schema);
|
||||||
qemuTestDriverFree(&driver);
|
qemuTestDriverFree(&driver);
|
||||||
|
@ -643,7 +643,7 @@ testCompareXMLToArgv(const void *data)
|
|||||||
virDomainChrSourceDef monitor_chr;
|
virDomainChrSourceDef monitor_chr;
|
||||||
g_autoptr(virConnect) conn = NULL;
|
g_autoptr(virConnect) conn = NULL;
|
||||||
virError *err = NULL;
|
virError *err = NULL;
|
||||||
char *log = NULL;
|
g_autofree char *log = NULL;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
qemuDomainObjPrivate *priv = NULL;
|
qemuDomainObjPrivate *priv = NULL;
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
@ -815,7 +815,6 @@ testCompareXMLToArgv(const void *data)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(log);
|
|
||||||
virDomainChrSourceDefClear(&monitor_chr);
|
virDomainChrSourceDefClear(&monitor_chr);
|
||||||
virObjectUnref(vm);
|
virObjectUnref(vm);
|
||||||
virIdentitySetCurrent(NULL);
|
virIdentitySetCurrent(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user