summaryrefslogtreecommitdiff
path: root/libnm
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-04 09:02:53 +0200
committerThomas Haller <thaller@redhat.com>2018-05-11 16:51:20 +0200
commitd4093a3a2cb8e23248fed4e80e84b8816d453323 (patch)
treea00c27bfd9a44beae131f6452bf69c282e24ed7e /libnm
parent5e6b0382ad672254bdabf1997ef36bdc4fa0e11f (diff)
downloadNetworkManager-d4093a3a2cb8e23248fed4e80e84b8816d453323.tar.gz
clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager service and compares the output. The output formats of nmcli are complicated and not easily understood. For example how --mode tabular|multiline interacts with selecting output-fields (--fields) and output modes ([default]|--terse|--pretty). Also, there are things like `nmcli connection show --order $FIELD_SPEC`. We need unit tests to ensure that we don't change the output accidentally.
Diffstat (limited to 'libnm')
-rw-r--r--libnm/nm-client.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index f748512283..18d3e318ce 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -110,6 +110,7 @@ typedef struct {
GDBusObjectManager *object_manager;
GCancellable *new_object_manager_cancellable;
struct udev *udev;
+ bool udev_inited:1;
} NMClientPrivate;
enum {
@@ -2603,9 +2604,14 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
NULL);
if (NM_IS_DEVICE (obj_nm)) {
priv = NM_CLIENT_GET_PRIVATE (self);
- if (!priv->udev)
- priv->udev = udev_new ();
- _nm_device_set_udev (NM_DEVICE (obj_nm), priv->udev);
+ if (G_UNLIKELY (!priv->udev_inited)) {
+ priv->udev_inited = TRUE;
+ /* for testing, we don't want to use udev in libnm. */
+ if (!nm_streq0 (g_getenv ("LIBNM_USE_NO_UDEV"), "1"))
+ priv->udev = udev_new ();
+ }
+ if (priv->udev)
+ _nm_device_set_udev (NM_DEVICE (obj_nm), priv->udev);
}
g_object_set_qdata_full (G_OBJECT (object), _nm_object_obj_nm_quark (),
obj_nm, g_object_unref);