mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemumonitorjsontest: Introduce DO_TEST_SIMPLE
This macro is there to test the simplest monitor functions we have, those in the form of: int ( *func) (qemuMonitorPtr). So far, we have seven such functions.
This commit is contained in:
parent
4f1b6df127
commit
2cf3a4e526
@ -31,6 +31,15 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
|
typedef struct _testQemuMonitorJSONSimpleFuncData testQemuMonitorJSONSimpleFuncData;
|
||||||
|
typedef testQemuMonitorJSONSimpleFuncData *testQemuMonitorJSONSimpleFuncDataPtr;
|
||||||
|
struct _testQemuMonitorJSONSimpleFuncData {
|
||||||
|
const char *cmd;
|
||||||
|
int (* func) (qemuMonitorPtr mon);
|
||||||
|
virDomainXMLOptionPtr xmlopt;
|
||||||
|
const char *reply;
|
||||||
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testQemuMonitorJSONGetStatus(const void *data)
|
testQemuMonitorJSONGetStatus(const void *data)
|
||||||
{
|
{
|
||||||
@ -998,11 +1007,36 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testQemuMonitorJSONSimpleFunc(const void *opaque)
|
||||||
|
{
|
||||||
|
const testQemuMonitorJSONSimpleFuncDataPtr data = (const testQemuMonitorJSONSimpleFuncDataPtr) opaque;
|
||||||
|
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||||
|
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
|
||||||
|
const char *reply = data->reply;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!reply)
|
||||||
|
reply = "{\"return\":{}}";
|
||||||
|
|
||||||
|
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (data->func(qemuMonitorTestGetMonitor(test)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
qemuMonitorTestFree(test);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
virDomainXMLOptionPtr xmlopt;
|
virDomainXMLOptionPtr xmlopt;
|
||||||
|
testQemuMonitorJSONSimpleFuncData simpleFunc;
|
||||||
|
|
||||||
#if !WITH_YAJL
|
#if !WITH_YAJL
|
||||||
fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
|
fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
|
||||||
@ -1019,6 +1053,12 @@ mymain(void)
|
|||||||
if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlopt) < 0) \
|
if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlopt) < 0) \
|
||||||
ret = -1
|
ret = -1
|
||||||
|
|
||||||
|
#define DO_TEST_SIMPLE(CMD, FNC, ...) \
|
||||||
|
simpleFunc = (testQemuMonitorJSONSimpleFuncData) {.cmd = CMD, .func = FNC, \
|
||||||
|
.xmlopt = xmlopt, __VA_ARGS__ }; \
|
||||||
|
if (virtTestRun(# FNC, 1, testQemuMonitorJSONSimpleFunc, &simpleFunc) < 0) \
|
||||||
|
ret = -1
|
||||||
|
|
||||||
DO_TEST(GetStatus);
|
DO_TEST(GetStatus);
|
||||||
DO_TEST(GetVersion);
|
DO_TEST(GetVersion);
|
||||||
DO_TEST(GetMachines);
|
DO_TEST(GetMachines);
|
||||||
@ -1033,6 +1073,13 @@ mymain(void)
|
|||||||
DO_TEST(SetObjectProperty);
|
DO_TEST(SetObjectProperty);
|
||||||
DO_TEST(GetDeviceAliases);
|
DO_TEST(GetDeviceAliases);
|
||||||
DO_TEST(CPU);
|
DO_TEST(CPU);
|
||||||
|
DO_TEST_SIMPLE("qmp_capabilities", qemuMonitorJSONSetCapabilities);
|
||||||
|
DO_TEST_SIMPLE("system_powerdown", qemuMonitorSystemPowerdown);
|
||||||
|
DO_TEST_SIMPLE("system_reset", qemuMonitorJSONSystemReset);
|
||||||
|
DO_TEST_SIMPLE("migrate_cancel", qemuMonitorJSONMigrateCancel);
|
||||||
|
DO_TEST_SIMPLE("inject-nmi", qemuMonitorJSONInjectNMI);
|
||||||
|
DO_TEST_SIMPLE("system_wakeup", qemuMonitorJSONSystemWakeup);
|
||||||
|
DO_TEST_SIMPLE("nbd-server-stop", qemuMonitorJSONNBDServerStop);
|
||||||
|
|
||||||
virObjectUnref(xmlopt);
|
virObjectUnref(xmlopt);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user