summaryrefslogtreecommitdiff
path: root/src/tests/test-general.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-02-05 16:24:27 +0100
committerThomas Haller <thaller@redhat.com>2017-02-10 14:43:24 +0100
commit93f7ab2c54096461bf03e3adf56955a681c95946 (patch)
tree485b7f1cc2bb138405cc4a9423f1e868a2ce92ce /src/tests/test-general.c
parenta8221323990c80fa4ad585388b213788f12917c9 (diff)
downloadNetworkManager-93f7ab2c54096461bf03e3adf56955a681c95946.tar.gz
core: consolidate sorting of connections by autoconnect/timestamp
NMPolicy's auto_activate_device() wants to sort by autoconnect-priority, nm_utils_cmp_connection_by_autoconnect_priority() but fallback to the default nm_settings_connection_cmp_default(), which includes the timestamp. Extend nm_settings_connection_cmp_default() to consider the autoconnect-priority as well. Thus change behavior so that nm_settings_connection_cmp_default() is the sort order that auto_activate_device() wants. That makes sense, as nm_settings_connection_cmp_default() already considered the ability to autoconnect as first. Hence, it should also honor the autoconnect priority. When doing that, rename nm_settings_connection_cmp_default() to nm_settings_connection_cmp_autoconnect_priority().
Diffstat (limited to 'src/tests/test-general.c')
-rw-r--r--src/tests/test-general.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index f8f8fa2606..ef1a4f2b6a 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -870,6 +870,12 @@ _create_connection_autoconnect (const char *id, gboolean autoconnect, int autoco
return c;
}
+static int
+_cmp_autoconnect_priority_p_with_data (gconstpointer pa, gconstpointer pb, gpointer user_data)
+{
+ return nm_utils_cmp_connection_by_autoconnect_priority (*((NMConnection **) pa), *((NMConnection **) pb));
+}
+
static void
_test_connection_sort_autoconnect_priority_one (NMConnection **list, gboolean shuffle)
{
@@ -892,7 +898,7 @@ _test_connection_sort_autoconnect_priority_one (NMConnection **list, gboolean sh
}
/* sort it... */
- g_ptr_array_sort_with_data (connections, nm_utils_cmp_connection_by_autoconnect_priority_p_with_data, NULL);
+ g_ptr_array_sort_with_data (connections, _cmp_autoconnect_priority_p_with_data, NULL);
for (i = 0; i < count; i++) {
if (list[i] == connections->pdata[i])