On Wed, Jan 11, 2017 at 10:48:18AM +0100, Peter Krempa wrote:
Similar to the existing qemuMonitorTestNewFromFile the *Full version
will allow to check both commands and supply responses for a better
monitor testing.
---
tests/qemumonitortestutils.c | 119 +++++++++++++++++++++++++++++++++++++++++++
tests/qemumonitortestutils.h | 3 ++
2 files changed, 122 insertions(+)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 50042f960..80136dc14 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1278,6 +1278,125 @@ qemuMonitorTestNewFromFile(const char *fileName,
}
+static int
+qemuMonitorTestFullAddItem(qemuMonitorTestPtr test,
+ const char *filename,
+ const char *command,
+ const char *response,
+ size_t line)
+{
+ char *cmderr;
+ int ret;
+
+ if (virAsprintf(&cmderr, "wrong expected command in %s:%zu: ",
+ filename, line) < 0)
+ return -1;
+
+ ret = qemuMonitorTestAddItemVerbatim(test, command, cmderr, response);
+
+ VIR_FREE(cmderr);
+ return ret;
+}
+
+
+/**
+ * qemuMonitorTestNewFromFileFull:
+ * @fileName: File name to load monitor replies from
+ * @driver: qemu driver object
+ * @vm: domain object (may be null if it's not needed by the test)
+ *
+ * Create a JSON test monitor simulator object and fill it with expected command
+ * sequence and replies specified in @fileName.
+ *
+ * The file contains a sequence of JSON commands and reply objects separated by
+ * empty lines. A command is followed by a reply. The QMP greeting is added
+ * automatically.
+ *
+ * Returns the monitor object on success; NULL on error.
+ */
+qemuMonitorTestPtr
+qemuMonitorTestNewFromFileFull(const char *fileName,
+ virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+{
+ qemuMonitorTestPtr ret = NULL;
+ char *jsonstr = NULL;
+ char *tmp;
+ size_t line = 0;
+
+ char *command = NULL;
+ char *response = NULL;
+ size_t commandln = 0;
+ char *cmderr = NULL;
The *cmderr* is not used anywhere so remove it.
ACK
Pavel