[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.7 v3 32/36] tests: add qtest_add_data_func
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH for-2.7 v3 32/36] tests: add qtest_add_data_func_full |
Date: |
Fri, 05 Aug 2016 09:12:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> Hi
>
> ----- Original Message -----
>> address@hidden writes:
>>
>> > From: Marc-André Lureau <address@hidden>
>> >
>> > Allows one to specify a destroy function for the test data.
>> >
>> > Signed-off-by: Marc-André Lureau <address@hidden>
>> > ---
>> > 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)(void))
>> > g_free(path);
>> > }
>> >
>> > +void qtest_add_data_func_full(const char *str, void *data,
>> > + void (*fn)(const void *),
>> > + GDestroyNotify data_free_func)
>> > +{
>> > + gchar *path = 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);
>>
>> Umm, are these function casts kosher?
>>
>> 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=2.22.0#n214
>
> See also: https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00073.html
>
>
>>
>> > +#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));
>> >
>> > /**
>> > - * 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 *));
>>
>> 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.
- [Qemu-devel] [PATCH for-2.7 v3 25/36] sd: free timer, (continued)
- [Qemu-devel] [PATCH for-2.7 v3 25/36] sd: free timer, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 26/36] qjson: free str, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 27/36] virtio-input: free config list, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 28/36] ipmi: free extern timer, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 29/36] usb: free USBDevice.strings, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 30/36] usb: free leaking path, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 31/36] bus: simplify name handling, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 32/36] tests: add qtest_add_data_func_full, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 33/36] tests: pc-cpu-test leaks fixes, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 34/36] tests: fix rsp leak in postcopy-test, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 36/36] tests: fix postcopy-test leaks, marcandre . lureau, 2016/08/03
- [Qemu-devel] [PATCH for-2.7 v3 35/36] ahci: fix sglist leak on retry, marcandre . lureau, 2016/08/03