Re: log_warning_error_tests()



On 16/06/2013 10:35, John Emmas wrote:

I'm not quite sure what 'g_pattern_match_simple()' does = but from what I can tell, if the supplied message matches "*g_print*assertion*failed*" the function simply returns.  Otherwise it sets G_LOG_FLAG_FATAL (which later causes the abort).  The problem in this case is that the message supplied from 'g_return_if_fail' is, in fact, "gmessages.c: line 1446: assertion 'format != NULL' failed"


Hmmm...  I managed to find a fix for this test failure.  It seems reasonable enough to me but I'd appreciate any comments.

Here's the failing test from line 575 of 'tests/testglib.c'

        g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                         "*g_print*assertion*failed*");
        g_print (NULL);

If I change it to this, the test passes:-

#ifdef _MSC_VER
        g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                         "*assertion*failed*");
#else
        g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                         "*g_print*assertion*failed*");
#endif
        g_print (NULL);

The problem seems to be that the macro 'g_return_if_fail' expands to a second macro which uses the identifier __PRETTY_FUNCTION__.  However, __PRETTY_FUNCTION__ is a gcc extension which is defined in glib/gmacros.h - but it's only defined for GNUC.  When building with MSVC the relevant function name (g_print, in this case) won't get included in any assertion text.  Does that make sense?

John


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