1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +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:
Peter Krempa 2023-05-22 16:30:59 +02:00
parent e79ccbae1c
commit f26923fb2e
2 changed files with 0 additions and 102 deletions

View File

@ -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)

View File

@ -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) \