mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
tests: Drop cleanup/error labels
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
74da85bcb9
commit
7c79cfe4da
@ -111,48 +111,45 @@ testQemuAgentFSFreeze(const void *data)
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
const char *mountpoints[] = {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"};
|
||||
int ret = -1;
|
||||
int rc;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze-list",
|
||||
"{ \"return\" : 5 }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze",
|
||||
"{ \"return\" : 7 }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if ((ret = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test),
|
||||
mountpoints, 5)) < 0)
|
||||
goto cleanup;
|
||||
if ((rc = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test),
|
||||
mountpoints, 5)) < 0)
|
||||
return -1;
|
||||
|
||||
if (ret != 5) {
|
||||
if (rc != 5) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"expected 5 frozen filesystems, got %d", ret);
|
||||
goto cleanup;
|
||||
"expected 5 frozen filesystems, got %d", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0)) < 0)
|
||||
goto cleanup;
|
||||
if ((rc = qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0)) < 0)
|
||||
return -1;
|
||||
|
||||
if (ret != 7) {
|
||||
if (rc != 7) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"expected 7 frozen filesystems, got %d", ret);
|
||||
goto cleanup;
|
||||
"expected 7 frozen filesystems, got %d", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -161,47 +158,44 @@ testQemuAgentFSThaw(const void *data)
|
||||
{
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
int ret = -1;
|
||||
int rc;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
||||
"{ \"return\" : 5 }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw",
|
||||
"{ \"return\" : 7 }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if ((ret = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||
goto cleanup;
|
||||
if ((rc = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||
return -1;
|
||||
|
||||
if (ret != 5) {
|
||||
if (rc != 5) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"expected 5 thawed filesystems, got %d", ret);
|
||||
goto cleanup;
|
||||
"expected 5 thawed filesystems, got %d", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||
goto cleanup;
|
||||
if ((rc = qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0)
|
||||
return -1;
|
||||
|
||||
if (ret != 7) {
|
||||
if (rc != 7) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"expected 7 thawed filesystems, got %d", ret);
|
||||
goto cleanup;
|
||||
"expected 7 thawed filesystems, got %d", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -210,27 +204,23 @@ testQemuAgentFSTrim(const void *data)
|
||||
{
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "guest-fstrim",
|
||||
"{ \"return\" : {} }",
|
||||
"minimum", "1337",
|
||||
NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentFSTrim(qemuMonitorTestGetAgent(test), 1337) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +229,6 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
||||
qemuMonitorTest **test,
|
||||
virDomainDef **def)
|
||||
{
|
||||
int ret = -1;
|
||||
g_autofree char *domain_filename = NULL;
|
||||
g_autoptr(qemuMonitorTest) ret_test = NULL;
|
||||
g_autoptr(virDomainDef) ret_def = NULL;
|
||||
@ -254,10 +243,10 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
||||
|
||||
if (!(ret_def = virDomainDefParseFile(domain_filename, xmlopt,
|
||||
NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(ret_test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(ret_test, "guest-get-fsinfo",
|
||||
"{\"return\": ["
|
||||
@ -293,14 +282,11 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt,
|
||||
" {\"name\": \"sdb1\","
|
||||
" \"mountpoint\": \"/mnt/disk\","
|
||||
" \"disk\": [], \"type\": \"xfs\"}]}") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
*test = g_steal_pointer(&ret_test);
|
||||
*def = g_steal_pointer(&ret_def);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -408,43 +394,39 @@ testQemuAgentSuspend(const void *data)
|
||||
{
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
int ret = -1;
|
||||
size_t i;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-suspend-ram",
|
||||
"{ \"return\" : {} }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-suspend-disk",
|
||||
"{ \"return\" : {} }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid",
|
||||
"{ \"return\" : {} }") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* try the commands - fail if ordering changes */
|
||||
for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++) {
|
||||
if (qemuAgentSuspend(qemuMonitorTestGetAgent(test), i) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -506,13 +488,12 @@ testQemuAgentShutdown(const void *data)
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
struct qemuAgentShutdownTestData priv;
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
||||
priv.mode = "halt";
|
||||
@ -520,14 +501,14 @@ testQemuAgentShutdown(const void *data)
|
||||
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
||||
qemuAgentShutdownTestMonitorHandler,
|
||||
&priv, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||
QEMU_AGENT_SHUTDOWN_HALT) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
|
||||
priv.mode = "powerdown";
|
||||
@ -535,14 +516,14 @@ testQemuAgentShutdown(const void *data)
|
||||
if (qemuMonitorTestAddHandler(test, "guest-shutdown",
|
||||
qemuAgentShutdownTestMonitorHandler,
|
||||
&priv, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||
QEMU_AGENT_SHUTDOWN_POWERDOWN) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
priv.event = QEMU_AGENT_EVENT_RESET;
|
||||
priv.mode = "reboot";
|
||||
@ -551,17 +532,17 @@ testQemuAgentShutdown(const void *data)
|
||||
"guest-shutdown",
|
||||
qemuAgentShutdownTestMonitorHandler,
|
||||
&priv, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||
QEMU_AGENT_SHUTDOWN_REBOOT) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* check negative response, so that we can verify that the agent breaks
|
||||
* out from sleep */
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-shutdown",
|
||||
"{\"error\":"
|
||||
@ -571,19 +552,16 @@ testQemuAgentShutdown(const void *data)
|
||||
" \"data\":{\"name\":\"guest-shutdown\"}"
|
||||
" }"
|
||||
"}") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentShutdown(qemuMonitorTestGetAgent(test),
|
||||
QEMU_AGENT_SHUTDOWN_REBOOT) != -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"agent shutdown command should have failed");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -626,75 +604,71 @@ testQemuAgentCPU(const void *data)
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
g_autofree qemuAgentCPUInfo *cpuinfo = NULL;
|
||||
int nvcpus;
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "guest-get-vcpus",
|
||||
testQemuAgentCPUResponse) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* get cpus */
|
||||
if ((nvcpus = qemuAgentGetVCPUs(qemuMonitorTestGetAgent(test),
|
||||
&cpuinfo)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (nvcpus != 4) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Expected '4' cpus, got '%d'", nvcpus);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* try to unplug one */
|
||||
if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||
"{ \"return\" : 1 }",
|
||||
"vcpus", testQemuAgentCPUArguments1,
|
||||
NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* try to hotplug two, second one will fail */
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||
"{ \"return\" : 1 }",
|
||||
"vcpus", testQemuAgentCPUArguments2,
|
||||
NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus",
|
||||
"{ \"error\" : \"random error\" }",
|
||||
"vcpus", testQemuAgentCPUArguments3,
|
||||
NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentUpdateCPUInfo(4, cpuinfo, nvcpus) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* this should fail */
|
||||
if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) != -1)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -706,37 +680,33 @@ testQemuAgentArbitraryCommand(const void *data)
|
||||
{
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
int ret = -1;
|
||||
g_autofree char *reply = NULL;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "ble",
|
||||
testQemuAgentArbitraryCommandResponse) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
||||
"{\"execute\":\"ble\"}",
|
||||
&reply,
|
||||
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"invalid processing of guest agent reply: "
|
||||
"got '%s' expected '%s'",
|
||||
reply, testQemuAgentArbitraryCommandResponse);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -755,36 +725,33 @@ testQemuAgentTimeout(const void *data)
|
||||
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
|
||||
g_autofree char *reply = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
return -1;
|
||||
|
||||
if (virTestGetExpensive() == 0) {
|
||||
ret = EXIT_AM_SKIP;
|
||||
goto cleanup;
|
||||
}
|
||||
if (virTestGetExpensive() == 0)
|
||||
return EXIT_AM_SKIP;
|
||||
|
||||
if (qemuMonitorTestAddHandler(test, NULL,
|
||||
qemuAgentTimeoutTestMonitorHandler,
|
||||
NULL, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0) != -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"agent command should have failed");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* test timeout */
|
||||
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddHandler(test,
|
||||
NULL,
|
||||
qemuAgentTimeoutTestMonitorHandler,
|
||||
NULL, NULL) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test),
|
||||
"{\"execute\":\"ble\"}",
|
||||
@ -792,13 +759,10 @@ testQemuAgentTimeout(const void *data)
|
||||
1) != -2) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"agent command didn't time out");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char testQemuAgentGetInterfacesResponse[] =
|
||||
|
@ -68,7 +68,6 @@ testQemuDataReset(testQemuData *data)
|
||||
static int
|
||||
testQemuCaps(const void *opaque)
|
||||
{
|
||||
int ret = -1;
|
||||
testQemuData *data = (void *) opaque;
|
||||
g_autofree char *repliesFile = NULL;
|
||||
g_autofree char *capsFile = NULL;
|
||||
@ -88,10 +87,10 @@ testQemuCaps(const void *opaque)
|
||||
|
||||
if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
binary = g_strdup_printf("/usr/bin/qemu-system-%s",
|
||||
data->archName);
|
||||
@ -99,17 +98,17 @@ testQemuCaps(const void *opaque)
|
||||
if (!(capsActual = virQEMUCapsNewBinary(binary)) ||
|
||||
virQEMUCapsInitQMPMonitor(capsActual,
|
||||
qemuMonitorTestGetMonitor(mon)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) {
|
||||
qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon));
|
||||
|
||||
if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virQEMUCapsInitQMPMonitorTCG(capsActual,
|
||||
qemuMonitorTestGetMonitor(mon)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* calculate fake microcode version based on filename for a reproducible
|
||||
* number for testing which does not change with the contents */
|
||||
@ -125,14 +124,12 @@ testQemuCaps(const void *opaque)
|
||||
}
|
||||
|
||||
if (!(actual = virQEMUCapsFormatCache(capsActual)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virTestCompareToFile(actual, capsFile) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,7 +100,6 @@ qemuMigParamsTestXML(const void *opaque)
|
||||
g_autoptr(virJSONValue) params = NULL;
|
||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||
g_autofree char *actualXML = NULL;
|
||||
int ret = -1;
|
||||
|
||||
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
||||
abs_srcdir, data->name);
|
||||
@ -108,27 +107,24 @@ qemuMigParamsTestXML(const void *opaque)
|
||||
abs_srcdir, data->name);
|
||||
|
||||
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
||||
¶ms) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!(migParams = qemuMigrationParamsFromJSON(params)))
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +140,6 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
g_autoptr(qemuMigrationParams) migParams = NULL;
|
||||
g_autofree char *actualJSON = NULL;
|
||||
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
||||
int ret = -1;
|
||||
|
||||
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
|
||||
abs_srcdir, data->name);
|
||||
@ -152,18 +147,18 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
abs_srcdir, data->name);
|
||||
|
||||
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon),
|
||||
¶msIn) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!(migParams = qemuMigrationParamsFromJSON(paramsIn)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!(paramsOut = qemuMigrationParamsToJSON(migParams)) ||
|
||||
!(actualJSON = virJSONValueToString(paramsOut, true)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (testQEMUSchemaValidateCommand("migrate-set-parameters",
|
||||
paramsOut,
|
||||
@ -174,16 +169,13 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
&debug) < 0) {
|
||||
VIR_TEST_VERBOSE("failed to validate migration params '%s' against QMP schema: %s",
|
||||
actualJSON, virBufferCurrentContent(&debug));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virTestCompareToFile(actualJSON, jsonFile) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,7 +243,6 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
||||
{
|
||||
const testGenericData *data = opaque;
|
||||
virDomainXMLOption *xmlopt = data->xmlopt;
|
||||
int ret = -1;
|
||||
int major;
|
||||
int minor;
|
||||
int micro;
|
||||
@ -264,7 +263,7 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
||||
" \"package\":\"\""
|
||||
" }"
|
||||
"}") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorTestAddItem(test, "query-version",
|
||||
"{ "
|
||||
@ -277,67 +276,64 @@ testQemuMonitorJSONGetVersion(const void *opaque)
|
||||
" \"package\":\"2.283.el6\""
|
||||
" }"
|
||||
"}") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
||||
&major, &minor, µ,
|
||||
&package) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (major != 1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Major %d was not 1", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (minor != 2) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Minor %d was not 2", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (micro != 3) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Micro %d was not 3", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (STRNEQ(package, "")) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Package %s was not ''", package);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
VIR_FREE(package);
|
||||
|
||||
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
||||
&major, &minor, µ,
|
||||
&package) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (major != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Major %d was not 0", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (minor != 11) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Minor %d was not 11", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (micro != 6) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Micro %d was not 6", major);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (STRNEQ(package, "2.283.el6")) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"Package %s was not '2.283.el6'", package);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -652,10 +648,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
||||
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSchema(xmlopt, schema);
|
||||
g_autofree char *jsonreply = NULL;
|
||||
g_autofree char *fulllabel = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!test)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!reply)
|
||||
reply = "";
|
||||
@ -668,7 +663,7 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
||||
|
||||
if (qemuMonitorTestAddItemExpect(test, "chardev-add",
|
||||
expectargs, true, jsonreply) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
data.chr = chr;
|
||||
data.fail = fail;
|
||||
@ -676,12 +671,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
||||
data.test = test;
|
||||
|
||||
if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1028,15 +1020,15 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
||||
" \"type\": \"child<piix3-usb-uhci>\"},"
|
||||
" {\"name\": \"type\", \"type\": \"string\"}"
|
||||
"]}") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONGetDeviceAliases(qemuMonitorTestGetMonitor(test),
|
||||
&aliases) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!aliases) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "no aliases returned");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
@ -1053,7 +1045,6 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2839,7 +2830,6 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
||||
g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
|
||||
g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
|
||||
g_autoptr(qemuMonitorCPUModelInfo) baseline = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
||||
return -1;
|
||||
@ -2864,26 +2854,26 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
||||
if (virCPUDefAddFeature(cpu_a, "feat_a", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
||||
virCPUDefAddFeature(cpu_a, "feat_b", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
||||
virCPUDefAddFeature(cpu_a, "feat_c", VIR_CPU_FEATURE_REQUIRE) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONGetCPUModelBaseline(qemuMonitorTestGetMonitor(test),
|
||||
cpu_a, cpu_b, &baseline) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!baseline) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"Baseline missing result");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (!baseline->name) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"Baseline missing model name");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (baseline->nprops != 2) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"Baseline missing properties");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
if (STRNEQ(baseline->props[0].name, "feat_a") ||
|
||||
!baseline->props[0].value.boolean ||
|
||||
@ -2891,13 +2881,10 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
||||
baseline->props[1].value.boolean) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
"Baseline property error");
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
||||
if (!(test->tmpdir = g_mkdtemp(tmpdir_template))) {
|
||||
virReportSystemError(errno, "%s",
|
||||
"Failed to create temporary directory");
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmpdir_template = NULL;
|
||||
@ -1026,14 +1026,14 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
||||
} else {
|
||||
test->vm = virDomainObjNew(xmlopt);
|
||||
if (!test->vm)
|
||||
goto error;
|
||||
return NULL;
|
||||
if (!(test->vm->def = virDomainDefNew(xmlopt)))
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virNetSocketNewListenUNIX(path, 0700, geteuid(), getegid(),
|
||||
&test->server) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
memset(src, 0, sizeof(*src));
|
||||
src->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
@ -1042,13 +1042,9 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt,
|
||||
path = NULL;
|
||||
|
||||
if (virNetSocketListen(test->server, 1) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
return g_steal_pointer(&test);
|
||||
|
||||
error:
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1200,12 +1196,12 @@ qemuMonitorTestNewFromFile(const char *fileName,
|
||||
|
||||
if (test) {
|
||||
if (qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
} else {
|
||||
/* Create new mocked monitor with our greeting */
|
||||
if (!(test = qemuMonitorTestNew(xmlopt, NULL, NULL,
|
||||
singleReply, NULL)))
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!eof) {
|
||||
@ -1220,12 +1216,9 @@ qemuMonitorTestNewFromFile(const char *fileName,
|
||||
}
|
||||
|
||||
if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
return g_steal_pointer(&test);
|
||||
|
||||
error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -1344,7 +1337,7 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
|
||||
if (response) {
|
||||
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
||||
response, commandln) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
command = NULL;
|
||||
response = NULL;
|
||||
}
|
||||
@ -1364,18 +1357,15 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
|
||||
if (!response) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "missing response for command "
|
||||
"on line '%zu' in '%s'", commandln, fileName);
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (qemuMonitorTestFullAddItem(ret, fileName, command,
|
||||
response, commandln) < 0)
|
||||
goto error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_steal_pointer(&ret);
|
||||
|
||||
error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user