From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cskiv-0001xM-1g for qemu-devel@nongnu.org; Tue, 28 Mar 2017 02:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cskir-0005Jl-R1 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 02:35:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cskir-0005Jd-Iw for qemu-devel@nongnu.org; Tue, 28 Mar 2017 02:35:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F1ADC1C5E04 for ; Tue, 28 Mar 2017 06:35:16 +0000 (UTC) References: <1490092792-30957-1-git-send-email-thuth@redhat.com> <1490092792-30957-3-git-send-email-thuth@redhat.com> <20170327142421.GF2373@work-vm> From: Thomas Huth Message-ID: <95bf59af-beeb-74bf-7819-f2a770b64263@redhat.com> Date: Tue, 28 Mar 2017 08:35:11 +0200 MIME-Version: 1.0 In-Reply-To: <20170327142421.GF2373@work-vm> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/3] libqtest: Add a generic function to run a callback function for every machine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: qemu-devel@nongnu.org, Markus Armbruster , Eduardo Habkost On 27.03.2017 16:24, Dr. David Alan Gilbert wrote: > * Thomas Huth (thuth@redhat.com) 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 >=20 > Having queued it, it's failing my test. >=20 > 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. >=20 > It fails with: > xen be core: xen be core: can't connect to xenstored > can't connect to xenstored > xen_init_pv: xen backend core setup failed > Broken pipe >=20 > I suggest you probably need to share the blacklist as well. >=20 > (Unqueued) >=20 > Dave >=20 >> --- >> 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(-) >> >> diff --git a/tests/libqtest.c b/tests/libqtest.c >> index c9b2d76..d8b8066 100644 >> --- a/tests/libqtest.c >> +++ b/tests/libqtest.c >> @@ -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 =3D qmp("{ 'execute': 'query-machines' }"); >> + g_assert(response); >> + list =3D qdict_get_qlist(response, "return"); >> + g_assert(list); >> + >> + for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { >> + minfo =3D qobject_to_qdict(qlist_entry_obj(p)); >> + g_assert(minfo); >> + qobj =3D qdict_get(minfo, "name"); >> + g_assert(qobj); >> + qstr =3D qobject_to_qstring(qobj); >> + g_assert(qstr); >> + mname =3D qstring_get_str(qstr); >> + cb(mname); >> + } >> + >> + qtest_end(); >> + QDECREF(response); >> +} [...] >> diff --git a/tests/qom-test.c b/tests/qom-test.c >> index d48f890..ab0595d 100644 >> --- a/tests/qom-test.c >> +++ b/tests/qom-test.c >> @@ -107,46 +107,22 @@ static void test_machine(gconstpointer data) >> g_free((void *)machine); >> } >> =20 >> -static void add_machine_test_cases(void) >> +static void add_machine_test_case(const char *mname) >> { >> const char *arch =3D qtest_get_arch(); >> - QDict *response, *minfo; >> - QList *list; >> - const QListEntry *p; >> - QObject *qobj; >> - QString *qstr; >> - const char *mname; >> =20 >> - qtest_start("-machine none"); >> - response =3D qmp("{ 'execute': 'query-machines' }"); >> - g_assert(response); >> - list =3D qdict_get_qlist(response, "return"); >> - g_assert(list); >> - >> - for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { >> - minfo =3D qobject_to_qdict(qlist_entry_obj(p)); >> - g_assert(minfo); >> - qobj =3D qdict_get(minfo, "name"); >> - g_assert(qobj); >> - qstr =3D qobject_to_qstring(qobj); >> - g_assert(qstr); >> - mname =3D qstring_get_str(qstr); >> - if (!is_blacklisted(arch, mname)) { >> - char *path =3D 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 =3D 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