From f26923fb2e49d544ef937cd34e6b0807fed9eb96 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 May 2023 16:30:59 +0200 Subject: [PATCH] qemuMonitorTestAddItemExpect: Remove unused helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/qemumonitortestutils.c | 95 ------------------------------------ tests/qemumonitortestutils.h | 7 --- 2 files changed, 102 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 40ef057271..9e6da78a8b 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -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) diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h index df0d544720..5de55172be 100644 --- a/tests/qemumonitortestutils.h +++ b/tests/qemumonitortestutils.h @@ -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) \