[PATCH 06/18] qemuMonitorTestAddItemExpect: Remove unused helper

Peter Krempa pkrempa at redhat.com
Thu May 25 15:13:33 UTC 2023


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 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) \
-- 
2.40.1



More information about the libvir-list mailing list