From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhzgc-00054U-64 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhzgX-0001Eu-M8 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:48:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhzgX-0001Ek-E1 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:48:09 -0400 References: <20160908084036.5938-1-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <869f8b57-873e-217b-bb9d-bd44d0e82bb8@redhat.com> Date: Thu, 8 Sep 2016 08:48:07 -0500 MIME-Version: 1.0 In-Reply-To: <20160908084036.5938-1-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="svpWBlLIanXE1piX5bP6IPP9oIWWpHQ55" Subject: Re: [Qemu-devel] [PATCHv5] 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?= , qemu-devel@nongnu.org Cc: armbru@redhat.com, peter.maydell@linaro.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --svpWBlLIanXE1piX5bP6IPP9oIWWpHQ55 From: Eric Blake To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , qemu-devel@nongnu.org Cc: armbru@redhat.com, peter.maydell@linaro.org Message-ID: <869f8b57-873e-217b-bb9d-bd44d0e82bb8@redhat.com> Subject: Re: [PATCHv5] tests: add qtest_add_data_func_full References: <20160908084036.5938-1-marcandre.lureau@redhat.com> In-Reply-To: <20160908084036.5938-1-marcandre.lureau@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/08/2016 03:40 AM, Marc-Andr=C3=A9 Lureau wrote: > Allows one to specify a destroy function for the test data. >=20 > Add a fallback using glib g_test_add_vtable() internal function, whose > signature changed over time. Tested with glib 2.22, 2.26 and 2.48, whic= h > according to git log should be enough to cover all variations. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > tests/libqtest.c | 19 +++++++++++++++++++ > tests/libqtest.h | 17 +++++++++++++++++ > 2 files changed, 36 insertions(+) >=20 > diff --git a/tests/libqtest.c b/tests/libqtest.c > index eb00f13..5f4450f 100644 > --- a/tests/libqtest.c > +++ b/tests/libqtest.c > @@ -758,6 +758,25 @@ void qtest_add_func(const char *str, void (*fn)(vo= id)) > g_free(path); > } > =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); > +#elif GLIB_CHECK_VERSION(2, 26, 0) > + /* back-compat casts, remove this once we can require new-enough g= lib */ > + g_test_add_vtable(path, 0, data, NULL, > + (GTestFixtureFunc)fn, (GTestFixtureFunc) data_fr= ee_func); > +#elif GLIB_CHECK_VERSION(2, 22, 0) Perhaps this could be written as #else, since we have no further alternatives (2.22.0 being our minimum). Up to the maintainer if it is worth changing. Otherwise I think the end result is reasonable, and you were able to avoid the leaks. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --svpWBlLIanXE1piX5bP6IPP9oIWWpHQ55 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX0WwXAAoJEKeha0olJ0Nq738H/2HwqYkpd+GyqAT+5E+1JwFL 4u4xeszASDdbsIv843xkx4+dFhS7kKPlZe+EgeL+u58o9GDREyoEruf0HWGBBqbS c3QSNw8ksuh6jdPaIATFlBdiEsCUCNClEGSSqJ25zhKtOU61WtfaGZLFA4cVI+Ie AMlBE3/HZ6ZAuZ3TC3ThjRnSCJXoufxPcPSywRuUPLKNg1Wvg6LxiuKt6q5ai+3y c2uCjoTZNZCoo6qAaDvd2OMeSXk1FL/UuSaDu6hMYjokW1yh7NvcQFMOmWchoRDO xrM/YhBVTSnoo7ZU62Gz06ms/+PIO8WbomECq/5yLqK5fThFm/k1L8VoQUXsfiI= =hdQV -----END PGP SIGNATURE----- --svpWBlLIanXE1piX5bP6IPP9oIWWpHQ55--