For each test monitor entry store an optional string which will allow to
identify it. This will be used later when checking that all registered
monitor commands were used.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/qemuagenttest.c | 17 ++++++++++++-----
tests/qemumonitortestutils.c | 10 ++++++++++
tests/qemumonitortestutils.h | 1 +
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 943251df77..2c3a1efb09 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -471,7 +471,8 @@ testQemuAgentShutdown(const void *data)
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
priv.mode = "halt";
- if (qemuMonitorTestAddHandler(test, qemuAgentShutdownTestMonitorHandler,
+ if (qemuMonitorTestAddHandler(test, "guest-shutdown",
+ qemuAgentShutdownTestMonitorHandler,
&priv, NULL) < 0)
goto cleanup;
@@ -485,7 +486,8 @@ testQemuAgentShutdown(const void *data)
priv.event = QEMU_AGENT_EVENT_SHUTDOWN;
priv.mode = "powerdown";
- if (qemuMonitorTestAddHandler(test, qemuAgentShutdownTestMonitorHandler,
+ if (qemuMonitorTestAddHandler(test, "guest-shutdown",
+ qemuAgentShutdownTestMonitorHandler,
&priv, NULL) < 0)
goto cleanup;
@@ -499,7 +501,9 @@ testQemuAgentShutdown(const void *data)
priv.event = QEMU_AGENT_EVENT_RESET;
priv.mode = "reboot";
- if (qemuMonitorTestAddHandler(test, qemuAgentShutdownTestMonitorHandler,
+ if (qemuMonitorTestAddHandler(test,
+ "guest-shutdown",
+ qemuAgentShutdownTestMonitorHandler,
&priv, NULL) < 0)
goto cleanup;
@@ -720,7 +724,8 @@ testQemuAgentTimeout(const void *data)
goto cleanup;
}
- if (qemuMonitorTestAddHandler(test, qemuAgentTimeoutTestMonitorHandler,
+ if (qemuMonitorTestAddHandler(test, NULL,
+ qemuAgentTimeoutTestMonitorHandler,
NULL, NULL) < 0)
goto cleanup;
@@ -734,7 +739,9 @@ testQemuAgentTimeout(const void *data)
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
goto cleanup;
- if (qemuMonitorTestAddHandler(test, qemuAgentTimeoutTestMonitorHandler,
+ if (qemuMonitorTestAddHandler(test,
+ NULL,
+ qemuAgentTimeoutTestMonitorHandler,
NULL, NULL) < 0)
goto cleanup;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index bc3b2f5f92..1af56c6d87 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -43,6 +43,7 @@
VIR_LOG_INIT("tests.qemumonitortestutils");
struct _qemuMonitorTestItem {
+ char *identifier;
qemuMonitorTestResponseCallback cb;
void *opaque;
virFreeCallback freecb;
@@ -88,6 +89,8 @@ qemuMonitorTestItemFree(qemuMonitorTestItemPtr item)
if (!item)
return;
+ g_free(item->identifier);
+
if (item->freecb)
(item->freecb)(item->opaque);
@@ -436,6 +439,7 @@ qemuMonitorTestFree(qemuMonitorTestPtr test)
int
qemuMonitorTestAddHandler(qemuMonitorTestPtr test,
+ const char *identifier,
qemuMonitorTestResponseCallback cb,
void *opaque,
virFreeCallback freecb)
@@ -445,6 +449,7 @@ qemuMonitorTestAddHandler(qemuMonitorTestPtr test,
if (VIR_ALLOC(item) < 0)
goto error;
+ item->identifier = g_strdup(identifier);
item->cb = cb;
item->freecb = freecb;
item->opaque = opaque;
@@ -617,6 +622,7 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test,
data->response = g_strdup(response);
return qemuMonitorTestAddHandler(test,
+ command_name,
qemuMonitorTestProcessCommandDefault,
data, qemuMonitorTestHandlerDataFree);
}
@@ -700,6 +706,7 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTestPtr test,
goto error;
return qemuMonitorTestAddHandler(test,
+ command,
qemuMonitorTestProcessCommandVerbatim,
data, qemuMonitorTestHandlerDataFree);
@@ -766,6 +773,7 @@ qemuMonitorTestAddAgentSyncResponse(qemuMonitorTestPtr test)
}
return qemuMonitorTestAddHandler(test,
+ "agent-sync",
qemuMonitorTestProcessGuestAgentSync,
NULL, NULL);
}
@@ -884,6 +892,7 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test,
va_end(args);
return qemuMonitorTestAddHandler(test,
+ cmdname,
qemuMonitorTestProcessCommandWithArgs,
data, qemuMonitorTestHandlerDataFree);
@@ -988,6 +997,7 @@ qemuMonitorTestAddItemExpect(qemuMonitorTestPtr test,
}
return qemuMonitorTestAddHandler(test,
+ cmdname,
qemuMonitorTestProcessCommandWithArgStr,
data, qemuMonitorTestHandlerDataFree);
diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h
index c693b626fc..384002d086 100644
--- a/tests/qemumonitortestutils.h
+++ b/tests/qemumonitortestutils.h
@@ -34,6 +34,7 @@ typedef int (*qemuMonitorTestResponseCallback)(qemuMonitorTestPtr test,
const char *message);
int qemuMonitorTestAddHandler(qemuMonitorTestPtr test,
+ const char *identifier,
qemuMonitorTestResponseCallback cb,
void *opaque,
virFreeCallback freecb);
--
2.26.0