libnm-glib: fix assertion-failure messages in test-remote-settings-client

test-remote-setting-client uses a macro:

    #define test_assert(condition) \
    do { \
        if (!G_LIKELY (condition)) \
            cleanup (); \
        g_assert (condition); \
    } while (0)

where cleanup() kills the fake remote-settings service and unrefs
settings. However, in many cases, "condition" would involve a test
against a connection that was owned by settings, so if the check
failed, the connection would end up getting freed by cleanup(), and so
then the second invocation of condition would result in the program
aborting on a failed check somewhere else (eg, "invalid unclassed
pointer in cast to 'NMConnection'") rather than displaying the failed
assertion that had gotten us to that point.

Fix this by not unreffing settings from cleanup(); in the normal exit
case we can just have main() unref it, and in the assertion-failed
case, we don't need to free things anyway.
This commit is contained in:
Dan Winship 2014-07-20 08:47:32 -04:00
parent bcd554724e
commit 396610d14a

View file

@ -44,8 +44,6 @@ NMRemoteConnection *remote = NULL;
static void
cleanup (void)
{
if (settings)
g_object_unref (settings);
kill (spid, SIGTERM);
}
@ -392,6 +390,7 @@ main (int argc, char **argv)
ret = g_test_run ();
cleanup ();
g_object_unref (settings);
dbus_g_connection_unref (bus);
return ret;