summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-12-06 18:57:28 +0100
committerThomas Haller <thaller@redhat.com>2019-12-10 07:53:25 +0100
commit4c08ec1575497c5fd8f68e8a7bf5b5c5724618f0 (patch)
treef0127172b97a8689d1b52c983cc83916ba18191d
parentd8850d589f9a03a5451c3fc92fd8d6f104566623 (diff)
downloadNetworkManager-th/polkit-permissions-cleanup.tar.gz
clients: in debug builds randomly use sync init of NMClient for testingth/polkit-permissions-cleanup
This affects nmtui and nm-cloud-setup, which use nmc_client_new_waitsync().
-rw-r--r--shared/nm-libnm-aux/nm-libnm-aux.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/shared/nm-libnm-aux/nm-libnm-aux.c b/shared/nm-libnm-aux/nm-libnm-aux.c
index 83b6f71b6b..169416b9c4 100644
--- a/shared/nm-libnm-aux/nm-libnm-aux.c
+++ b/shared/nm-libnm-aux/nm-libnm-aux.c
@@ -102,6 +102,31 @@ nmc_client_new_waitsync (GCancellable *cancellable,
};
va_list ap;
+#if NM_MORE_ASSERTS > 10
+ /* The sync initialization of NMClient is generally a bad idea, because it
+ * brings the overhead of an additional GMainContext. Anyway, since our own
+ * code no longer uses that, we hardly test those code paths. But they should
+ * work just the same. Randomly use instead the sync initialization in a debug
+ * build... */
+ if ((g_random_int () % 2) == 0) {
+ gboolean success;
+
+ va_start (ap, first_property_name);
+ nmc = NM_CLIENT (g_object_new_valist (NM_TYPE_CLIENT, first_property_name, ap));
+ va_end (ap);
+
+ /* iterate the context at least once, just so that the behavior from POV of the
+ * caller is roughly the same. */
+ g_main_context_iteration (nm_client_get_main_context (nmc), FALSE);
+
+ success = g_initable_init (G_INITABLE (nmc),
+ cancellable,
+ error);
+ NM_SET_OUT (out_nmc, g_steal_pointer (&nmc));
+ return success;
+ }
+#endif
+
va_start (ap, first_property_name);
nmc = nmc_client_new_async_valist (cancellable,
_nmc_client_new_waitsync_cb,