From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVZJL-0004NJ-EM for qemu-devel@nongnu.org; Fri, 05 Aug 2016 03:12:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVZJG-0008AM-Uh for qemu-devel@nongnu.org; Fri, 05 Aug 2016 03:12:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVZJG-0008AC-M4 for qemu-devel@nongnu.org; Fri, 05 Aug 2016 03:12:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FA2A811A2 for ; Fri, 5 Aug 2016 07:12:46 +0000 (UTC) From: Markus Armbruster References: <20160803145541.15355-1-marcandre.lureau@redhat.com> <20160803145541.15355-33-marcandre.lureau@redhat.com> <87eg64d1oy.fsf@dusky.pond.sub.org> <1124142587.1104537.1470323156384.JavaMail.zimbra@redhat.com> Date: Fri, 05 Aug 2016 09:12:42 +0200 In-Reply-To: <1124142587.1104537.1470323156384.JavaMail.zimbra@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Thu, 4 Aug 2016 11:05:56 -0400 (EDT)") Message-ID: <87bn177kph.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.7 v3 32/36] tests: add qtest_add_data_func_full List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: marcandre lureau , qemu-devel@nongnu.org, pbonzini@redhat.com Marc-Andr=C3=A9 Lureau writes: > Hi > > ----- Original Message ----- >> marcandre.lureau@redhat.com writes: >>=20 >> > From: Marc-Andr=C3=A9 Lureau >> > >> > Allows one to specify a destroy function for the test data. >> > >> > Signed-off-by: Marc-Andr=C3=A9 Lureau >> > --- >> > tests/libqtest.c | 15 +++++++++++++++ >> > tests/libqtest.h | 7 ++++++- >> > 2 files changed, 21 insertions(+), 1 deletion(-) >> > >> > diff --git a/tests/libqtest.c b/tests/libqtest.c >> > index eb00f13..9e2d0cd 100644 >> > --- a/tests/libqtest.c >> > +++ b/tests/libqtest.c >> > @@ -758,6 +758,21 @@ void qtest_add_func(const char *str, void (*fn)(v= oid)) >> > g_free(path); >> > } >> >=20=20 >> > +void qtest_add_data_func_full(const char *str, void *data, >> > + void (*fn)(const void *), >> > + GDestroyNotify data_free_func) >> > +{ >> > + gchar *path =3D g_strdup_printf("/%s/%s", qtest_get_arch(), str); >> > +#if GLIB_CHECK_VERSION(2, 34, 0) >> > + g_test_add_data_func_full(path, data, fn, data_free_func); >> > +#else >> > + /* back-compat casts, remove this once we can require new-enough = glib >> > */ >> > + g_test_add_vtable(path, 0, data, NULL, >> > + (GTestFixtureFunc) fn, (GTestFixtureFunc) >> > data_free_func); >>=20 >> Umm, are these function casts kosher? >>=20 >> I can't find documentation for g_test_add_vtable(). Got a pointer for >> me? Sure GLib 2.22 provides it? > > Yes, https://git.gnome.org/browse/glib/tree/glib/gtestutils.h?h=3D2.22.0#= n214 > > See also: https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00073.= html > > >>=20 >> > +#endif >> > + g_free(path); >> > +} >> > + >> > void qtest_add_data_func(const char *str, const void *data, >> > void (*fn)(const void *)) >> > { >> > diff --git a/tests/libqtest.h b/tests/libqtest.h >> > index 37f37ad..e4c9c39 100644 >> > --- a/tests/libqtest.h >> > +++ b/tests/libqtest.h >> > @@ -413,15 +413,20 @@ const char *qtest_get_arch(void); >> > void qtest_add_func(const char *str, void (*fn)(void)); >> >=20=20 >> > /** >> > - * qtest_add_data_func: >> > + * qtest_add_data_func_full: >> > * @str: Test case path. >> > * @data: Test case data >> > * @fn: Test case function >> > + * @data_free_func: GDestroyNotify for data >> > * >> > * Add a GTester testcase with the given name, data and function. >> > * The path is prefixed with the architecture under test, as >> > * returned by qtest_get_arch(). Recommend to mention that @data is passed to @data_free_func() on test completion. >> > */ >> > +void qtest_add_data_func_full(const char *str, void *data, >> > + void (*fn)(const void *), >> > + GDestroyNotify data_free_func); >> > + >> > void qtest_add_data_func(const char *str, const void *data, >> > void (*fn)(const void *)); >>=20 >> Please keep qtest_add_data_func() documented. > > Ok (I thought it was quite enough based on the _full description) You could try something like /** * qtest_add_data_func and qtest_add_data_func_full: * @str: Test case path. * @data: Test case data * @fn: Test case function * @data_free_func: GDestroyNotify for data * * Add a GTester testcase with the given name, data and function. * The path is prefixed with the architecture under test, as * returned by qtest_get_arch(). */ void qtest_add_data_func_full(const char *str, void *data, void (*fn)(const void *), GDestroyNotify data_free_func); void qtest_add_data_func(const char *str, const void *data, GTK-Doc extraction wouldn't cope with it, but we're not using it[*]. Or something like /** * qtest_add_data_func: * @str: Test case path. * @data: Test case data * @fn: Test case function * @data_free_func: GDestroyNotify for data * * Add a GTester testcase with the given name, data and function. * The path is prefixed with the architecture under test, as * returned by qtest_get_arch(). */ void qtest_add_data_func_full(const char *str, void *data, void (*fn)(const void *), GDestroyNotify data_free_func); /* Like qtest_add_data_func_full() with a null last argument */ void qtest_add_data_func(const char *str, const void *data, Again, no GTK-Doc support, and again, I don't care. [*] We only pay its price of admission: gratuitous waste of screen space by repeating the obvious.