Message ID | 31c4ba8885438636d2125723b19307ab99dca300.1355435056.git.jbaron@redhat.com |
---|---|
State | New |
Headers | show |
Am 13.12.2012 23:02, schrieb Jason Baron: > 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 Adding a dependency to every qtest is calling for a $(qtest-obj-y) to administer that list in a central location. I am expecting the number of tests to grow significantly over time. Andreas
On Fri, Dec 14, 2012 at 01:07:24AM +0100, Andreas Färber wrote: > Am 13.12.2012 23:02, schrieb Jason Baron: > > 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 > > Adding a dependency to every qtest is calling for a $(qtest-obj-y) to > administer that list in a central location. I am expecting the number of > tests to grow significantly over time. > > Andreas > ok, seems as though we can add $(test-qapi-obj-y) $(qom-obj-y), etc. to the qtest-obj-y target, to simplify things a bit. I'll re-post that as a separate patch. Thanks, -Jason
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: