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 hereI 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
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/spice-devel
