g_test_trap_fork() fails on g_return_...



Hi all,

I'd like to sanitize my library by passing invalid values to GObject
properties. I built a test case with g_test_trap_fork() to trap
eventual segmentation faults, so far without success. I tracked down
the problem to this case:


#include <glib.h>
#include <stdlib.h>

static void dummy(void)
{
    g_return_if_reached();
}

static void
test_trap_fork(void)
{
    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR)) {
        dummy();
        exit(0);
    }
    g_test_trap_assert_passed();
}


int
main(int argc, char *argv[])
{
    g_test_init(&argc, &argv, NULL);

    g_test_add_func("/trap_fork test", test_trap_fork);

    return g_test_run();
}


The above test fails (glib-2.22.4), no way to succesful returns after
a g_return_...() macro is encountered.

Any idea?

Thank you.
-- 
Nicola



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