Re: [spice-common v3 3/7] log: Add test case for logging code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 17, 2015 at 10:43:05PM +0100, Victor Toso wrote:
> > +/* Checks that spice_return_if_fail() aborts by default */
> > +static void test_spice_fatal_return_if_fail(void)
> > +{
> > +    if (g_test_subprocess()) {
> > +        spice_return_if_fail(FALSE);
> > +        return;
> > +    }
> > +    g_test_trap_subprocess(NULL, 0, 0);
> > +    g_test_trap_assert_failed();
> > +}
> > +
> > +/* Checks that g_return_if_fail() does not abort by default */
> > +static void test_spice_non_fatal_g_return_if_fail(void)
> > +{
> > +    char *pattern = g_strconcat ("*", G_STRFUNC, "*", NULL);
> > +    g_test_log_set_fatal_handler(non_fatal_warnings_criticals, pattern);
> > +
> > +    if (g_test_subprocess()) {
> > +        g_return_if_fail(FALSE);
> 
> pattern leaks here

I know, but I don't think I can easily free it unless I move the
g_return_if_fail() to a separate helper function. If
g_test_log_set_fatal_handler() is not called, then g_return_if_fail()
will abort. I did not manage to find some preprocessor magic to build
a compile-time string (rather than an allocated one) with the content I
want. I can add a comment making it explicit that the leak is on
purpose. The g_return_if_fail() runs in a subprocess which will end
right after that call, so in my opinion this leak is acceptable.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]