mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
qemuMonitorTestAddItemExpect: Remove unused helper
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e79ccbae1c
commit
f26923fb2e
@ -859,101 +859,6 @@ qemuMonitorTestAddItemParams(qemuMonitorTest *test,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTest *test,
|
||||
qemuMonitorTestItem *item,
|
||||
const char *cmdstr)
|
||||
{
|
||||
struct qemuMonitorTestHandlerData *data = item->opaque;
|
||||
g_autoptr(virJSONValue) val = NULL;
|
||||
virJSONValue *args;
|
||||
g_autofree char *argstr = NULL;
|
||||
const char *cmdname;
|
||||
|
||||
if (!(val = virJSONValueFromString(cmdstr)))
|
||||
return -1;
|
||||
|
||||
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
||||
qemuMonitorTestError("Missing command name in %s", cmdstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (STRNEQ(data->command_name, cmdname)) {
|
||||
qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(args = virJSONValueObjectGet(val, "arguments"))) {
|
||||
qemuMonitorTestError("Missing arguments section for command '%s'",
|
||||
data->command_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* convert the arguments to string */
|
||||
if (!(argstr = virJSONValueToString(args, false)))
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* arguments checked out, return the response */
|
||||
return qemuMonitorTestAddResponse(test, data->response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuMonitorTestAddItemExpect:
|
||||
*
|
||||
* @test: test monitor object
|
||||
* @cmdname: command name
|
||||
* @cmdargs: expected arguments of the command
|
||||
* @apostrophe: convert apostrophes (') in @cmdargs to quotes (")
|
||||
* @response: simulated response of the command
|
||||
*
|
||||
* Simulates a qemu monitor command. Checks that the 'arguments' of the qmp
|
||||
* command are expected. If @apostrophe is true apostrophes are converted to
|
||||
* quotes for simplification of writing the strings into code.
|
||||
*/
|
||||
int
|
||||
qemuMonitorTestAddItemExpect(qemuMonitorTest *test,
|
||||
const char *cmdname,
|
||||
const char *cmdargs,
|
||||
bool apostrophe,
|
||||
const char *response)
|
||||
{
|
||||
struct qemuMonitorTestHandlerData *data;
|
||||
|
||||
data = g_new0(struct qemuMonitorTestHandlerData, 1);
|
||||
|
||||
data->command_name = g_strdup(cmdname);
|
||||
data->response = g_strdup(response);
|
||||
data->expectArgs = g_strdup(cmdargs);
|
||||
|
||||
if (apostrophe) {
|
||||
char *tmp = data->expectArgs;
|
||||
|
||||
while (*tmp != '\0') {
|
||||
if (*tmp == '\'')
|
||||
*tmp = '"';
|
||||
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
|
||||
qemuMonitorTestAddHandler(test,
|
||||
cmdname,
|
||||
qemuMonitorTestProcessCommandWithArgStr,
|
||||
data, qemuMonitorTestHandlerDataFree);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuMonitorTestEOFNotify(qemuMonitor *mon G_GNUC_UNUSED,
|
||||
virDomainObj *vm G_GNUC_UNUSED)
|
||||
|
@ -81,13 +81,6 @@ qemuMonitorTestAddItemParams(qemuMonitorTest *test,
|
||||
...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
|
||||
int
|
||||
qemuMonitorTestAddItemExpect(qemuMonitorTest *test,
|
||||
const char *cmdname,
|
||||
const char *cmdargs,
|
||||
bool apostrophe,
|
||||
const char *response);
|
||||
|
||||
#define qemuMonitorTestNewSimple(xmlopt) \
|
||||
qemuMonitorTestNew(xmlopt, NULL, NULL, NULL)
|
||||
#define qemuMonitorTestNewSchema(xmlopt, schema) \
|
||||
|
Loading…
Reference in New Issue
Block a user