[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] qtest: extend qtest_qmp() to fill in the reply
From: |
Jason Baron |
Subject: |
[Qemu-devel] [PATCH 2/3] qtest: extend qtest_qmp() to fill in the reply |
Date: |
Thu, 13 Dec 2012 17:02:22 -0500 |
From: Jason Baron <address@hidden>
Introduce:
Add void qtest_qmp_resp(QTestState *s, QString *resp, const char *fmt, ...)
which allows a response string to be filled in.
Signed-off-by: Jason Baron <address@hidden>
---
tests/Makefile | 6 +++---
tests/libqtest.c | 17 ++++++++++-------
tests/libqtest.h | 4 +++-
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
index b60f0fb..30a101d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -74,10 +74,10 @@ tests/test-qmp-input-strict$(EXESUF):
tests/test-qmp-input-strict.o $(test-qapi-
tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o
tests/test-qmp-marshal.o $(test-qapi-obj-y)
tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o
$(test-qapi-obj-y)
-tests/rtc-test$(EXESUF): tests/rtc-test.o $(trace-obj-y)
+tests/rtc-test$(EXESUF): tests/rtc-test.o $(trace-obj-y) qstring.o
tests/m48t59-test$(EXESUF): tests/m48t59-test.o $(trace-obj-y)
-tests/fdc-test$(EXESUF): tests/fdc-test.o tests/libqtest.o $(trace-obj-y)
-tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/libqtest.o $(trace-obj-y)
+tests/fdc-test$(EXESUF): tests/fdc-test.o tests/libqtest.o $(trace-obj-y)
qstring.o
+tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/libqtest.o
$(trace-obj-y) qstring.o
# QTest rules
diff --git a/tests/libqtest.c b/tests/libqtest.c
index f3dd4e4..71c9eb4 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -288,7 +288,7 @@ redo:
return words;
}
-void qtest_qmp(QTestState *s, const char *fmt, ...)
+void qtest_qmp_resp(QTestState *s, QString *resp, const char *fmt, ...)
{
va_list ap;
bool has_reply = false;
@@ -313,16 +313,19 @@ void qtest_qmp(QTestState *s, const char *fmt, ...)
fprintf(stderr, "Broken pipe\n");
exit(1);
}
-
- switch (c) {
- case '{':
+ if (c == '{') {
nesting++;
has_reply = true;
- break;
- case '}':
+ }
+ if (c == '}') {
nesting--;
- break;
}
+ if (has_reply && resp) {
+ qstring_append_chr(resp, c);
+ }
+ }
+ if (has_reply && resp) {
+ qstring_append_chr(resp, '\0');
}
}
diff --git a/tests/libqtest.h b/tests/libqtest.h
index c8ade85..6441e50 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>
+#include "qstring.h"
typedef struct QTestState QTestState;
@@ -44,7 +45,8 @@ void qtest_quit(QTestState *s);
*
* Sends a QMP message to QEMU
*/
-void qtest_qmp(QTestState *s, const char *fmt, ...);
+void qtest_qmp_resp(QTestState *s, QString *resp, const char *fmt, ...);
+#define qtest_qmp(s, fmt, ...) qtest_qmp_resp(s, NULL, fmt, ## __VA_ARGS__)
/**
* qtest_get_irq:
--
1.7.1
[Qemu-devel] [PATCH 3/3] qtest: add migrate-test, Jason Baron, 2012/12/13