Add a tester for HMP commands
cover Add a tester for HMP commands
We currently do not test HMP commands automatically yet, so if they break, we do not notice this until somebody runs into the problem (like the "info qtree" problem that we recently had on qemu-system-ppc64). So let's add a simple tester that runs some HMP commands to check if they can crash or abort QEMU.
Note: Three boards are currently still blacklisted in the third patch. I've added the problems to our BiteSizeTasks wiki page, so I hope they will get fixed by GSoC students or somebody else soon. Once the problems are fixed, the blacklisting can be removed in the tester, too.
Thomas Huth (3):
libqtest: Ignore QMP events when parsing the response for HMP commands
libqtest: Add a generic function to run a callback function for every
machine
tests: Add a tester for HMP commands
tests/Makefile.include | 2 + tests/libqtest.c | 36 +++++++++++ tests/libqtest.h | 8 +++ tests/pc-cpu-test.c | 95 +++++++++++------------------ tests/qom-test.c | 36 ++--------- tests/test-hmp.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 248 insertions(+), 89 deletions(-) create mode 100644 tests/test-hmp.c
Signature · 1 line
1.8.3.1
PATCH 1/3 libqtest: Ignore QMP events when parsing the response for HMP commands
When running certain HMP commands (like "device_del") via QMP, we can sometimes get a QMP event in the response first, so that the "g_assert(ret)" statement in qtest_hmp() triggers and the test fails. So ignore such QMP events when looking for the real return value from QMP.
--- tests/libqtest.c | 6 ++++++ 1 file changed, 6 insertions(+)
tests/libqtest.c +6 -0
@@ -580,6 +580,12 @@ char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)" 'arguments': {'command-line': %s}}" , cmd); ret =g_strdup (qdict_get_try_str (resp,"return" )); +while (ret ==NULL &&qdict_get_try_str (resp,"event" )) { +/* Ignore asynchronous QMP events */ +QDECREF (resp); + resp =qtest_qmp_receive (s); + ret =g_strdup (qdict_get_try_str (resp,"return" )); + }g_assert (ret);QDECREF (resp);g_free (cmd);
Signature · 1 line
1.8.3.1
PATCH 2/3 libqtest: Add a generic function to run a callback function for every machine
In reply to Thomas HuthSome tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)
tests/libqtest.c +30 -0
@@ -938,3 +938,33 @@ bool qtest_big_endian(QTestState *s) {return s->big_endian; } + +void qtest_cb_for_every_machine (void (*cb)(const char *machine)) +{ +QDict *response, *minfo; +QList *list; +const QListEntry *p; +QObject *qobj; +QString *qstr; +const char *mname; + +qtest_start ("-machine none" ); + response =qmp ("{ 'execute': 'query-machines' }" ); +g_assert (response); + list =qdict_get_qlist (response,"return" ); +g_assert (list); + +for (p =qlist_first (list); p; p =qlist_next (p)) { + minfo =qobject_to_qdict (qlist_entry_obj (p)); +g_assert (minfo); + qobj =qdict_get (minfo,"name" ); +g_assert (qobj); + qstr =qobject_to_qstring (qobj); +g_assert (qstr); + mname =qstring_get_str (qstr); +cb (mname); + } + +qtest_end (); +QDECREF (response); +}
tests/libqtest.h +8 -0
@@ -917,4 +917,12 @@ void qmp_fd_send(int fd, const char *fmt, ...);QDict *qmp_fdv (int fd,const char *fmt,va_list ap);QDict *qmp_fd (int fd,const char *fmt, ...); +/** +* qtest_cb_for_every_machine: +* @cb: Pointer to the callback function +* +* Call a callback function for every name of all available machines. +*/ +void qtest_cb_for_every_machine (void (*cb)(const char *machine)); +#endif
tests/pc-cpu-test.c +36 -59
112 lines not on this page · raw message
tests/qom-test.c +6 -30
@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)g_free ((void *)machine); } -static void add_machine_test_cases (void ) +static void add_machine_test_case (const char *mname) {const char *arch =qtest_get_arch (); -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!is_blacklisted (arch, mname)) { -char *path =g_strdup_printf ("qom/%s" , mname); -qtest_add_data_func (path,g_strdup (mname), test_machine); -g_free (path); - } +if (!is_blacklisted (arch, mname)) { +char *path =g_strdup_printf ("qom/%s" , mname); +qtest_add_data_func (path,g_strdup (mname), test_machine); +g_free (path); } - -qtest_end (); -QDECREF (response); }int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL ); -add_machine_test_cases (); +qtest_cb_for_every_machine (add_machine_test_case);return g_test_run (); }
Signature · 1 line
1.8.3.1
PATCH 3/3 tests: Add a tester for HMP commands
In reply to Thomas HuthHMP commands do not get any automatic testing yet, so on certain QEMU machines, some HMP commands were causing crashes in the past. Thus we should test HMP commands in our test suite, too, to avoid that such problems creep in again in the future.
--- tests/Makefile.include | 2 + tests/test-hmp.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 tests/test-hmp.c
tests/Makefile.include +2 -0
@@ -331,6 +331,7 @@ check-qtest-xtensaeb-y = $(check-qtest-xtensa-y) check-qtest-s390x-y = tests/boot-serial-test$(EXESUF) check-qtest-generic-y += tests/qom-test$(EXESUF) +check-qtest-generic-y += tests/test-hmp$(EXESUF) qapi-schema += alternate-any.json qapi-schema += alternate-array.json
@@ -716,6 +717,7 @@ tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/display-vga-test$(EXESUF): tests/display-vga-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o +tests/test-hmp$(EXESUF): tests/test-hmp.o tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-pc-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) tests/nvme-test$(EXESUF): tests/nvme-test.o
tests/test-hmp.c new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 1/3] libqtest: Ignore QMP events when parsing the response for HMP commands
In reply to Thomas HuthQuoted 10 lines · Thomas Huth
When running certain HMP commands (like "
device_del") via QMP, we can sometimes get a QMP event in the response first, so that the "g_assert(ret)" statement inqtest_hmp()triggers and the test fails. So ignore such QMP events when looking for the real return value from QMP.Signed-off-by Thomas Huth <[email protected]>--- tests/libqtest.c | 6 ++++++ 1 file changed, 6 insertions(+)
qmp.py keeps a queue of events so they can be processed later. I guess an event queue will be needed eventually because discarding events makes it hard to write reliable test cases that check for events.
But as long as current qtests work correctly:
Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine
In reply to Thomas HuthQuoted 11 lines · Thomas Huth
Some tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
Signed-off-by Thomas Huth <[email protected]>--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)
Re: [Qemu-devel] [PATCH 3/3] tests: Add a tester for HMP commands
In reply to Thomas HuthQuoted 11 lines · Thomas Huth
HMP commands do not get any automatic testing yet, so on certain QEMU machines, some HMP commands were causing crashes in the past. Thus we should test HMP commands in our test suite, too, to avoid that such problems creep in again in the future.
Signed-off-by Thomas Huth <[email protected]>--- tests/Makefile.include | 2 + tests/test-hmp.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 tests/test-hmp.c
Re: [Qemu-devel] [PATCH 1/3] libqtest: Ignore QMP events when parsing the response for HMP commands
In reply to Stefan HajnocziQuoted 7 lines · Stefan Hajnoczi
Quoted 6 lines · Thomas Huth
When running certain HMP commands (like "
device_del") via QMP, we can sometimes get a QMP event in the response first, so that the "g_assert(ret)" statement inqtest_hmp()triggers and the test fails. So ignore such QMP events when looking for the real return value from QMP.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Thomas Huth <[email protected]>--- tests/libqtest.c | 6 ++++++ 1 file changed, 6 insertions(+)
qmp.pykeeps a queue of events so they can be processed later. I guess an event queue will be needed eventually because discarding events makes it hard to write reliable test cases that check for events.
Yes, but in that case the test likely should not use the hmp() functions at all and use qmp directly.
Quoted 3 lines
But as long as current qtests work correctly:
Reviewed-by Stefan Hajnoczi <[email protected]>
Thanks!
Thomas
Quoted 10 lines · * Thomas Huth ([email protected]) wrote:
We currently do not test HMP commands automatically yet, so if they break, we do not notice this until somebody runs into the problem (like the "info qtree" problem that we recently had on qemu-system-ppc64). So let's add a simple tester that runs some HMP commands to check if they can crash or abort QEMU.
Note: Three boards are currently still blacklisted in the third patch. I've added the problems to our BiteSizeTasks wiki page, so I hope they will get fixed by GSoC students or somebody else soon. Once the problems are fixed, the blacklisting can be removed in the tester, too.
Queued
Quoted 6 lines
Thomas Huth (3):
libqtest: Ignore QMP events when parsing the response for HMP commands
libqtest: Add a generic function to run a callback function for every
machine
tests: Add a tester for HMP commands
Quoted 12 lines
tests/Makefile.include | 2 + tests/libqtest.c | 36 +++++++++++ tests/libqtest.h | 8 +++ tests/pc-cpu-test.c | 95 +++++++++++------------------ tests/qom-test.c | 36 ++--------- tests/test-hmp.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 248 insertions(+), 89 deletions(-) create mode 100644 tests/test-hmp.cSignature · 1 line
1.8.3.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine
In reply to Thomas HuthQuoted 5 lines · * Thomas Huth ([email protected]) wrote:
Some tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
Signed-off-by Thomas Huth <[email protected]>
Having queued it, it's failing my test.
The reason is that qom-tests.c has a blacklist which blacklists Xen; however your new generic function doesn't have the blacklist, so when you run HMP commands on all machines it tries to run it on Xen since my PC has the Xen libraries installed (so builds with Xen support) but isn't a Xen guest.
It fails with:
xen be core: xen be core: can't connect to xenstored can't connect to xenstoredxen_init_pv: xen backend core setup failed Broken pipe
I suggest you probably need to share the blacklist as well.
(Unqueued)
Dave
Quoted 241 lines
--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)tests/libqtest.c +30
-0@@ -938,3 +938,33 @@ bool qtest_big_endian(QTestState *s) {return s->big_endian; } + +void qtest_cb_for_every_machine (void (*cb)(const char *machine)) +{ +QDict *response, *minfo; +QList *list; +const QListEntry *p; +QObject *qobj; +QString *qstr; +const char *mname; + +qtest_start ("-machine none" ); + response =qmp ("{ 'execute': 'query-machines' }" ); +g_assert (response); + list =qdict_get_qlist (response,"return" ); +g_assert (list); + +for (p =qlist_first (list); p; p =qlist_next (p)) { + minfo =qobject_to_qdict (qlist_entry_obj (p)); +g_assert (minfo); + qobj =qdict_get (minfo,"name" ); +g_assert (qobj); + qstr =qobject_to_qstring (qobj); +g_assert (qstr); + mname =qstring_get_str (qstr); +cb (mname); + } + +qtest_end (); +QDECREF (response); +}tests/libqtest.h +8
-0@@ -917,4 +917,12 @@ void qmp_fd_send(int fd, const char *fmt, ...);QDict *qmp_fdv (int fd,const char *fmt,va_list ap);QDict *qmp_fd (int fd,const char *fmt, ...); +/** +* qtest_cb_for_every_machine: +* @cb: Pointer to the callback function +* +* Call a callback function for every name of all available machines. +*/ +void qtest_cb_for_every_machine (void (*cb)(const char *machine)); +#endif tests/pc-cpu-test.c +36
-59@@ -79,69 +79,46 @@ static void test_data_free(gpointer data)g_free (pc); } -static void add_pc_test_cases (void ) +static void add_pc_test_case (const char *mname) { -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname;char *path;PCTestData *data; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!g_str_has_prefix (mname,"pc-" )) { -continue ; - } - data =g_malloc (sizeof (PCTestData)); - data->machine =g_strdup (mname); - data->cpu_model ="Haswell" ;/* 1.3+ theoretically */ - data->sockets =1 ; - data->cores =3 ; - data->threads =2 ; - data->maxcpus = data->sockets * data->cores * data->threads *2 ; -if (g_str_has_suffix (mname,"-1.4" ) || - (strcmp (mname,"pc-1.3" ) ==0 ) || - (strcmp (mname,"pc-1.2" ) ==0 ) || - (strcmp (mname,"pc-1.1" ) ==0 ) || - (strcmp (mname,"pc-1.0" ) ==0 ) || - (strcmp (mname,"pc-0.15" ) ==0 ) || - (strcmp (mname,"pc-0.14" ) ==0 ) || - (strcmp (mname,"pc-0.13" ) ==0 ) || - (strcmp (mname,"pc-0.12" ) ==0 ) || - (strcmp (mname,"pc-0.11" ) ==0 ) || - (strcmp (mname,"pc-0.10" ) ==0 )) { - path =g_strdup_printf ("cpu/%s/init/%ux%ux%u&maxcpus=%u" , - mname, data->sockets, data->cores, - data->threads, data->maxcpus); -qtest_add_data_func_full (path, data, test_pc_without_cpu_add, - test_data_free); -g_free (path); - }else { - path =g_strdup_printf ("cpu/%s/add/%ux%ux%u&maxcpus=%u" , - mname, data->sockets, data->cores, - data->threads, data->maxcpus); -qtest_add_data_func_full (path, data, test_pc_with_cpu_add, - test_data_free); -g_free (path); - } +if (!g_str_has_prefix (mname,"pc-" )) { +return ; + } + data =g_malloc (sizeof (PCTestData)); + data->machine =g_strdup (mname); + data->cpu_model ="Haswell" ;/* 1.3+ theoretically */ + data->sockets =1 ; + data->cores =3 ; + data->threads =2 ; + data->maxcpus = data->sockets * data->cores * data->threads *2 ; +if (g_str_has_suffix (mname,"-1.4" ) || + (strcmp (mname,"pc-1.3" ) ==0 ) || + (strcmp (mname,"pc-1.2" ) ==0 ) || + (strcmp (mname,"pc-1.1" ) ==0 ) || + (strcmp (mname,"pc-1.0" ) ==0 ) || + (strcmp (mname,"pc-0.15" ) ==0 ) || + (strcmp (mname,"pc-0.14" ) ==0 ) || + (strcmp (mname,"pc-0.13" ) ==0 ) || + (strcmp (mname,"pc-0.12" ) ==0 ) || + (strcmp (mname,"pc-0.11" ) ==0 ) || + (strcmp (mname,"pc-0.10" ) ==0 )) { + path =g_strdup_printf ("cpu/%s/init/%ux%ux%u&maxcpus=%u" , + mname, data->sockets, data->cores, + data->threads, data->maxcpus); +qtest_add_data_func_full (path, data, test_pc_without_cpu_add, + test_data_free); +g_free (path); + }else { + path =g_strdup_printf ("cpu/%s/add/%ux%ux%u&maxcpus=%u" , + mname, data->sockets, data->cores, + data->threads, data->maxcpus); +qtest_add_data_func_full (path, data, test_pc_with_cpu_add, + test_data_free); +g_free (path); } -QDECREF (response); -qtest_end (); }int main (int argc,char **argv)@@ -151,7 +128,7 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { -add_pc_test_cases (); +qtest_cb_for_every_machine (add_pc_test_case); }return g_test_run ();tests/qom-test.c +6
-30@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)g_free ((void *)machine); } -static void add_machine_test_cases (void ) +static void add_machine_test_case (const char *mname) {const char *arch =qtest_get_arch (); -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!is_blacklisted (arch, mname)) { -char *path =g_strdup_printf ("qom/%s" , mname); -qtest_add_data_func (path,g_strdup (mname), test_machine); -g_free (path); - } +if (!is_blacklisted (arch, mname)) { +char *path =g_strdup_printf ("qom/%s" , mname); +qtest_add_data_func (path,g_strdup (mname), test_machine); +g_free (path); } - -qtest_end (); -QDECREF (response); }int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL ); -add_machine_test_cases (); +qtest_cb_for_every_machine (add_machine_test_case);return g_test_run (); }Signature · 1 line
1.8.3.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine
Quoted 72 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Thomas Huth ([email protected]) wrote:
Some tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
Signed-off-by Thomas Huth <[email protected]>Having queued it, it's failing my test.
The reason is that
qom-tests.chas a blacklist which blacklists Xen; however your new generic function doesn't have the blacklist, so when you run HMP commands on all machines it tries to run it on Xen since my PC has the Xen libraries installed (so builds with Xen support) but isn't a Xen guest.It fails with:
xen be core: xen be core: can't connect to xenstored can't connect to xenstoredxen_init_pv: xen backend core setup failed Broken pipeI suggest you probably need to share the blacklist as well.
(Unqueued)
Dave
Quoted 45 lines
--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)tests/libqtest.c +30
-0@@ -938,3 +938,33 @@ bool qtest_big_endian(QTestState *s) {return s->big_endian; } + +void qtest_cb_for_every_machine (void (*cb)(const char *machine)) +{ +QDict *response, *minfo; +QList *list; +const QListEntry *p; +QObject *qobj; +QString *qstr; +const char *mname; + +qtest_start ("-machine none" ); + response =qmp ("{ 'execute': 'query-machines' }" ); +g_assert (response); + list =qdict_get_qlist (response,"return" ); +g_assert (list); + +for (p =qlist_first (list); p; p =qlist_next (p)) { + minfo =qobject_to_qdict (qlist_entry_obj (p)); +g_assert (minfo); + qobj =qdict_get (minfo,"name" ); +g_assert (qobj); + qstr =qobject_to_qstring (qobj); +g_assert (qstr); + mname =qstring_get_str (qstr); +cb (mname); + } + +qtest_end (); +QDECREF (response); +}
[...]
Quoted 35 lines
Quoted 35 lines
tests/qom-test.c +1
-23@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)g_free ((void *)machine); } -static void add_machine_test_cases (void ) +static void add_machine_test_case (const char *mname) {const char *arch =qtest_get_arch (); -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!is_blacklisted (arch, mname)) { -char *path =g_strdup_printf ("qom/%s" , mname);
Quoted 8 lines
tests/qom-test.c static void test_machine(gconstpointer data) · line 118
Quoted 8 lines
tests/qom-test.c +4
-3-qtest_add_data_func (path,g_strdup (mname), test_machine); -g_free (path); - } +if (!is_blacklisted (arch, mname)) { +char *path =g_strdup_printf ("qom/%s" , mname); +qtest_add_data_func (path,g_strdup (mname), test_machine); +g_free (path); }
Not sure what is going wrong here ... the "!is_blacklisted" check is still here, so why is it trying to start a xen machine here?
Looks like I need to install those xen libraries here, too ...
Thomas
Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine
Quoted 112 lines · * Thomas Huth ([email protected]) wrote:
Quoted 72 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Thomas Huth ([email protected]) wrote:
Some tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
Signed-off-by Thomas Huth <[email protected]>Having queued it, it's failing my test.
The reason is that
qom-tests.chas a blacklist which blacklists Xen; however your new generic function doesn't have the blacklist, so when you run HMP commands on all machines it tries to run it on Xen since my PC has the Xen libraries installed (so builds with Xen support) but isn't a Xen guest.It fails with:
xen be core: xen be core: can't connect to xenstored can't connect to xenstoredxen_init_pv: xen backend core setup failed Broken pipeI suggest you probably need to share the blacklist as well.
(Unqueued)
Dave
Quoted 45 lines
--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)tests/libqtest.c +30
-0@@ -938,3 +938,33 @@ bool qtest_big_endian(QTestState *s) {return s->big_endian; } + +void qtest_cb_for_every_machine (void (*cb)(const char *machine)) +{ +QDict *response, *minfo; +QList *list; +const QListEntry *p; +QObject *qobj; +QString *qstr; +const char *mname; + +qtest_start ("-machine none" ); + response =qmp ("{ 'execute': 'query-machines' }" ); +g_assert (response); + list =qdict_get_qlist (response,"return" ); +g_assert (list); + +for (p =qlist_first (list); p; p =qlist_next (p)) { + minfo =qobject_to_qdict (qlist_entry_obj (p)); +g_assert (minfo); + qobj =qdict_get (minfo,"name" ); +g_assert (qobj); + qstr =qobject_to_qstring (qobj); +g_assert (qstr); + mname =qstring_get_str (qstr); +cb (mname); + } + +qtest_end (); +QDECREF (response); +}[...]
Quoted 38 lines
Quoted 38 lines
tests/qom-test.c +1
-26@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)g_free ((void *)machine); } -static void add_machine_test_cases (void ) +static void add_machine_test_case (const char *mname) {const char *arch =qtest_get_arch (); -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!is_blacklisted (arch, mname)) { -char *path =g_strdup_printf ("qom/%s" , mname); -qtest_add_data_func (path,g_strdup (mname), test_machine); -g_free (path); - }
Quoted 8 lines
Quoted 5 lines
tests/qom-test.c static void test_machine(gconstpointer data) · line 118
Quoted 5 lines
tests/qom-test.c +4
-0+if (!is_blacklisted (arch, mname)) { +char *path =g_strdup_printf ("qom/%s" , mname); +qtest_add_data_func (path,g_strdup (mname), test_machine); +g_free (path); }Not sure what is going wrong here ... the "!is_blacklisted" check is still here, so why is it trying to start a xen machine here?
I don't think it's this test that fails, I think it's the new one you add in the last patch but for the same reason.
Quoted 1 line
Looks like I need to install those xen libraries here, too ...
I think it's xen-libs and xen-devel you need.
Dave
Quoted 3 lines
Thomas
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine
Quoted 122 lines · Dr. David Alan Gilbert
Quoted 112 lines · * Thomas Huth ([email protected]) wrote:
Quoted 72 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Thomas Huth ([email protected]) wrote:
Some tests need to run single tests for every available machine of the current QEMU binary. To avoid code duplication, let's extract this code that deals with 'query-machines' into a separate function.
Signed-off-by Thomas Huth <[email protected]>Having queued it, it's failing my test.
The reason is that
qom-tests.chas a blacklist which blacklists Xen; however your new generic function doesn't have the blacklist, so when you run HMP commands on all machines it tries to run it on Xen since my PC has the Xen libraries installed (so builds with Xen support) but isn't a Xen guest.It fails with:
xen be core: xen be core: can't connect to xenstored can't connect to xenstoredxen_init_pv: xen backend core setup failed Broken pipeI suggest you probably need to share the blacklist as well.
(Unqueued)
Dave
Quoted 45 lines
--- tests/libqtest.c | 30 +++++++++++++++++ tests/libqtest.h | 8 +++++ tests/pc-cpu-test.c | 95 ++++++++++++++++++++--------------------------------- tests/qom-test.c | 36 ++++---------------- 4 files changed, 80 insertions(+), 89 deletions(-)tests/libqtest.c +30
-0@@ -938,3 +938,33 @@ bool qtest_big_endian(QTestState *s) {return s->big_endian; } + +void qtest_cb_for_every_machine (void (*cb)(const char *machine)) +{ +QDict *response, *minfo; +QList *list; +const QListEntry *p; +QObject *qobj; +QString *qstr; +const char *mname; + +qtest_start ("-machine none" ); + response =qmp ("{ 'execute': 'query-machines' }" ); +g_assert (response); + list =qdict_get_qlist (response,"return" ); +g_assert (list); + +for (p =qlist_first (list); p; p =qlist_next (p)) { + minfo =qobject_to_qdict (qlist_entry_obj (p)); +g_assert (minfo); + qobj =qdict_get (minfo,"name" ); +g_assert (qobj); + qstr =qobject_to_qstring (qobj); +g_assert (qstr); + mname =qstring_get_str (qstr); +cb (mname); + } + +qtest_end (); +QDECREF (response); +}[...]
Quoted 38 lines
Quoted 38 lines
tests/qom-test.c +1
-26@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)g_free ((void *)machine); } -static void add_machine_test_cases (void ) +static void add_machine_test_case (const char *mname) {const char *arch =qtest_get_arch (); -QDict *response, *minfo; -QList *list; -const QListEntry *p; -QObject *qobj; -QString *qstr; -const char *mname; -qtest_start ("-machine none" ); - response =qmp ("{ 'execute': 'query-machines' }" ); -g_assert (response); - list =qdict_get_qlist (response,"return" ); -g_assert (list); - -for (p =qlist_first (list); p; p =qlist_next (p)) { - minfo =qobject_to_qdict (qlist_entry_obj (p)); -g_assert (minfo); - qobj =qdict_get (minfo,"name" ); -g_assert (qobj); - qstr =qobject_to_qstring (qobj); -g_assert (qstr); - mname =qstring_get_str (qstr); -if (!is_blacklisted (arch, mname)) { -char *path =g_strdup_printf ("qom/%s" , mname); -qtest_add_data_func (path,g_strdup (mname), test_machine); -g_free (path); - }Quoted 8 lines
Quoted 5 lines
tests/qom-test.c static void test_machine(gconstpointer data) · line 118
Quoted 5 lines
tests/qom-test.c +4
-0+if (!is_blacklisted (arch, mname)) { +char *path =g_strdup_printf ("qom/%s" , mname); +qtest_add_data_func (path,g_strdup (mname), test_machine); +g_free (path); }Not sure what is going wrong here ... the "!is_blacklisted" check is still here, so why is it trying to start a xen machine here?
Quoted 2 lines
I don't think it's this test that fails, I think it's the new one you add in the last patch but for the same reason.
Stupid me, I just read your reply way too fast (I just read qom-test.c there and then somehow thought you were talking about a problem in that file instead).
Quoted 3 lines
Quoted 1 line
Looks like I need to install those xen libraries here, too ...
I think it's xen-libs and xen-devel you need.
Thanks, I can reproduce the issue now ... I'll send a v2 with a fix.
Thomas