Commit 56ddc890 authored by Thomas Haller's avatar Thomas Haller

shared: restore compat code in nm-glib.h for 2.32 compatibility

In commit 8a46b25c, NetworkManager
bumped its glib dependency to 2.40 or newer.

"nm-glib.h" header is precisely the compatiblity implementation that we
use to cope with older glib versions. Note, that the same implementation
is also used by applet and VPN plugins.

However, applet and VPN plugins don't yet require 2.40 glib. Also,
they don't yet require NetworkManager 1.12.0 API (which was the one
that bumped the glib requirement to 2.40). Hence, when "nm-glib.h"
is used in applet or VPN, it must still cope with older versions,
although, the code is not used by NetworkManager itself.

Partly revert 8a46b25c so that nm-glib.h
again works for 2.32 or newer.

The same is true, also for "nm-test-utils.h", which is also used by
applet and VPN plugins.
parent 29c9ef3f
This diff is collapsed.
......@@ -344,6 +344,8 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
__nmtst_internal.assert_logging = !!assert_logging;
nm_g_type_init ();
is_debug = g_test_verbose ();
nmtst_debug = g_getenv ("NMTST_DEBUG");
......@@ -550,8 +552,13 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
*out_set_logging = TRUE;
#endif
g_assert (success);
#if GLIB_CHECK_VERSION(2,34,0)
if (__nmtst_internal.no_expect_message)
g_log_set_always_fatal (G_LOG_FATAL_MASK);
#else
/* g_test_expect_message() is a NOP, so allow any messages */
g_log_set_always_fatal (G_LOG_FATAL_MASK);
#endif
} else if (__nmtst_internal.no_expect_message) {
/* We have a test that would be assert_logging, but the user specified no_expect_message.
* This transforms g_test_expect_message() into a NOP, but we also have to relax
......@@ -571,9 +578,14 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
}
#endif
} else {
#if GLIB_CHECK_VERSION(2,34,0)
/* We were called not to set logging levels. This means, that the user
* expects to assert against (all) messages. Any uncought message is fatal. */
g_log_set_always_fatal (G_LOG_LEVEL_MASK);
#else
/* g_test_expect_message() is a NOP, so allow any messages */
g_log_set_always_fatal (G_LOG_FATAL_MASK);
#endif
}
if ((!__nmtst_internal.assert_logging || (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message)) &&
......@@ -640,6 +652,7 @@ nmtst_test_quick (void)
return __nmtst_internal.test_quick;
}
#if GLIB_CHECK_VERSION(2,34,0)
#undef g_test_expect_message
#define g_test_expect_message(...) \
G_STMT_START { \
......@@ -647,7 +660,9 @@ nmtst_test_quick (void)
if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) { \
g_debug ("nmtst: assert-logging: g_test_expect_message %s", G_STRINGIFY ((__VA_ARGS__))); \
} else { \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
g_test_expect_message (__VA_ARGS__); \
G_GNUC_END_IGNORE_DEPRECATIONS \
} \
} G_STMT_END
#undef g_test_assert_expected_messages_internal
......@@ -661,8 +676,11 @@ nmtst_test_quick (void)
if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) \
g_debug ("nmtst: assert-logging: g_test_assert_expected_messages(%s, %s:%d, %s)", _domain?:"", _file?:"", _line, _func?:""); \
\
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
g_test_assert_expected_messages_internal (_domain, _file, _line, _func); \
G_GNUC_END_IGNORE_DEPRECATIONS \
} G_STMT_END
#endif
#define NMTST_EXPECT(domain, level, msg) g_test_expect_message (domain, level, msg)
......@@ -1735,7 +1753,7 @@ _nmtst_assert_connection_has_settings (NMConnection *connection, gboolean has_at
va_start (ap, has_at_most);
while ((name = va_arg (ap, const char *))) {
if (!g_hash_table_add (names, (gpointer) name))
if (!nm_g_hash_table_add (names, (gpointer) name))
g_assert_not_reached ();
g_ptr_array_add (names_arr, (gpointer) name);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment