mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
qemumonitorjsontest: Use VIR_AUTOPTR support
Simplify the GEN_TEST_FUNC() and target of the DO_TEST_SIMPLE() macros by using autoptr support. Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
2ea60b6f7e
commit
09083437ff
@ -1268,26 +1268,22 @@ testQemuMonitorJSONSimpleFunc(const void *opaque)
|
|||||||
testQemuMonitorJSONSimpleFuncDataPtr data =
|
testQemuMonitorJSONSimpleFuncDataPtr data =
|
||||||
(testQemuMonitorJSONSimpleFuncDataPtr) opaque;
|
(testQemuMonitorJSONSimpleFuncDataPtr) opaque;
|
||||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||||
qemuMonitorTestPtr test = qemuMonitorTestNewSchema(xmlopt, data->schema);
|
|
||||||
const char *reply = data->reply;
|
const char *reply = data->reply;
|
||||||
int ret = -1;
|
VIR_AUTOPTR(qemuMonitorTest) test = NULL;
|
||||||
|
|
||||||
if (!test)
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!reply)
|
if (!reply)
|
||||||
reply = "{\"return\":{}}";
|
reply = "{\"return\":{}}";
|
||||||
|
|
||||||
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0)
|
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (data->func(qemuMonitorTestGetMonitor(test)) < 0)
|
if (data->func(qemuMonitorTestGetMonitor(test)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
qemuMonitorTestFree(test);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GEN_TEST_FUNC(funcName, ...) \
|
#define GEN_TEST_FUNC(funcName, ...) \
|
||||||
@ -1296,26 +1292,22 @@ testQemuMonitorJSON ## funcName(const void *opaque) \
|
|||||||
{ \
|
{ \
|
||||||
const testQemuMonitorJSONSimpleFuncData *data = opaque; \
|
const testQemuMonitorJSONSimpleFuncData *data = opaque; \
|
||||||
virDomainXMLOptionPtr xmlopt = data->xmlopt; \
|
virDomainXMLOptionPtr xmlopt = data->xmlopt; \
|
||||||
qemuMonitorTestPtr test = qemuMonitorTestNewSchema(xmlopt, data->schema); \
|
|
||||||
const char *reply = data->reply; \
|
const char *reply = data->reply; \
|
||||||
int ret = -1; \
|
VIR_AUTOPTR(qemuMonitorTest) test = NULL; \
|
||||||
\
|
\
|
||||||
if (!test) \
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) \
|
||||||
return -1; \
|
return -1; \
|
||||||
\
|
\
|
||||||
if (!reply) \
|
if (!reply) \
|
||||||
reply = "{\"return\":{}}"; \
|
reply = "{\"return\":{}}"; \
|
||||||
\
|
\
|
||||||
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0) \
|
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0) \
|
||||||
goto cleanup; \
|
return -1; \
|
||||||
\
|
\
|
||||||
if (funcName(qemuMonitorTestGetMonitor(test), __VA_ARGS__) < 0) \
|
if (funcName(qemuMonitorTestGetMonitor(test), __VA_ARGS__) < 0) \
|
||||||
goto cleanup; \
|
return -1; \
|
||||||
\
|
\
|
||||||
ret = 0; \
|
return 0; \
|
||||||
cleanup: \
|
|
||||||
qemuMonitorTestFree(test); \
|
|
||||||
return ret; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
|
GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user