All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <mlureau@redhat.com>
Cc: marcandre lureau <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org, pbonzini@redhat.com
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	[thread overview]
Message-ID: <87bn177kph.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1124142587.1104537.1470323156384.JavaMail.zimbra@redhat.com> ("Marc-André Lureau"'s message of "Thu, 4 Aug 2016 11:05:56 -0400 (EDT)")

Marc-André Lureau <mlureau@redhat.com> writes:

> Hi
>
> ----- Original Message -----
>> marcandre.lureau@redhat.com writes:
>> 
>> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
>> >
>> > Allows one to specify a destroy function for the test data.
>> >
>> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> > ---
>> >  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.

  reply	other threads:[~2016-08-05  7:12 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 14:55 [Qemu-devel] [PATCH for-2.7 v3 00/36] Various memory leak fixes marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 01/36] build-sys: fix building with make CFLAGS=.. argument marcandre.lureau
2016-08-03 15:58   ` Paolo Bonzini
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 02/36] tests: fix test-qga leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 03/36] qga: free the whole blacklist marcandre.lureau
2016-08-04 13:25   ` Markus Armbruster
2016-08-04 13:47     ` Marc-André Lureau
2016-08-04 14:39       ` Markus Armbruster
2016-08-04 14:59         ` Marc-André Lureau
2016-08-05  7:06           ` Markus Armbruster
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 04/36] qga: free remaining leaking state marcandre.lureau
2016-08-04 13:38   ` Markus Armbruster
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 05/36] tests: fix test-cutils leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 06/36] tests: fix test-vmstate leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 07/36] tests: fix test-iov leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 08/36] qdist: fix entries memory leak marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 09/36] tests: fix check-qom-interface leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 10/36] tests: fix check-qom-proplist leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 11/36] tests: fix small leak in test-io-channel-command marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 12/36] tests: fix leak in test-string-input-visitor marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 13/36] portio: keep references on portio marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 14/36] numa: do not leak NumaOptions marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 15/36] pc: simplify passing qemu_irq marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 16/36] pc: don't leak a20_line marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 17/36] machine: use class base init generated name marcandre.lureau
2016-08-04 13:56   ` Markus Armbruster
2016-08-04 14:31     ` Marc-André Lureau
2016-08-04 15:26       ` Markus Armbruster
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 18/36] acpi-build: fix array leak marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 19/36] char: free the tcp connection data when closing marcandre.lureau
2016-08-03 15:32   ` Paolo Bonzini
2016-08-03 15:40     ` Marc-André Lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 20/36] char: free MuxDriver " marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 21/36] tests: fix qom-test leaks marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 22/36] pc: free i8259 marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 23/36] pc: keep gsi reference marcandre.lureau
2016-08-04 14:45   ` Markus Armbruster
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 24/36] ahci: free irqs array marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 25/36] sd: free timer marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 26/36] qjson: free str marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 27/36] virtio-input: free config list marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 28/36] ipmi: free extern timer marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 29/36] usb: free USBDevice.strings marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 30/36] usb: free leaking path marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 31/36] bus: simplify name handling marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 32/36] tests: add qtest_add_data_func_full marcandre.lureau
2016-08-04 14:54   ` Markus Armbruster
2016-08-04 15:05     ` Marc-André Lureau
2016-08-05  7:12       ` Markus Armbruster [this message]
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 33/36] tests: pc-cpu-test leaks fixes marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 34/36] tests: fix rsp leak in postcopy-test marcandre.lureau
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 35/36] ahci: fix sglist leak on retry marcandre.lureau
2016-08-04 14:46   ` Markus Armbruster
2016-08-04 21:16     ` John Snow
2016-08-03 14:55 ` [Qemu-devel] [PATCH for-2.7 v3 36/36] tests: fix postcopy-test leaks marcandre.lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bn177kph.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.