summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-06-18 10:49:46 +0200
committerThomas Haller <thaller@redhat.com>2018-06-18 10:55:40 +0200
commit7e118c00916aa7dd3f04752debbcc09569d6effe (patch)
tree66aa5f47e0de7181593f4e836a8ff37a3e922a9d
parentfb9edd5eddfd69a8c6eb5d1ad32b24cc33a3cb5d (diff)
downloadNetworkManager-7e118c00916aa7dd3f04752debbcc09569d6effe.tar.gz
tests: fix race in setting signal strength for Wi-Fi AP in NM stub
This opens the tests up to races. If we want to change the strength, we need to do it in a controlled, race-free manner. This is especially the case, because clients/tests run a large number of nmcli instances in parallel, and it's thus racy which signal the nmcli processes will see. This also fixes a bug at self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength) @strength must be a D-Bus type, so that python-dbus knows the correct type for serialization.
-rwxr-xr-xtools/test-networkmanager-service.py26
1 files changed, 2 insertions, 24 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py
index ab63b60a83..c55955d99d 100755
--- a/tools/test-networkmanager-service.py
+++ b/tools/test-networkmanager-service.py
@@ -864,8 +864,6 @@ class WifiAp(ExportedObj):
strength = Util.random_int(self.path, 100)
self.ssid = ssid
- self.strength_counter = 0
- self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
props = {
PRP_WIFI_AP_FLAGS: dbus.UInt32(flags),
@@ -881,17 +879,6 @@ class WifiAp(ExportedObj):
self.dbus_interface_add(IFACE_WIFI_AP, props, WifiAp.PropertiesChanged)
- def __del__(self):
- if self.strength_id > 0:
- GLib.source_remove(self.strength_id)
- self.strength_id = 0
-
- def strength_cb(self, ignored):
- self.strength_counter += 1
- strength = Util.random_int(self.path + str(self.strength_counter), 100)
- self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength)
- return True
-
@dbus.service.signal(IFACE_WIFI_AP, signature='a{sv}')
def PropertiesChanged(self, changed):
pass
@@ -991,25 +978,16 @@ class WimaxNsp(ExportedObj):
ExportedObj.__init__(self, ExportedObj.create_path(WimaxNsp))
- self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None)
+ strength = Util.random_int(self.path, 100)
props = {
PRP_WIMAX_NSP_NAME: name,
- PRP_WIMAX_NSP_SIGNAL_QUALITY: dbus.UInt32(random.randint(0, 100)),
+ PRP_WIMAX_NSP_SIGNAL_QUALITY: dbus.UInt32(strength),
PRP_WIMAX_NSP_NETWORK_TYPE: dbus.UInt32(NM.WimaxNspNetworkType.HOME),
}
self.dbus_interface_add(IFACE_WIMAX_NSP, props, WimaxNsp.PropertiesChanged)
- def __del__(self):
- if self.strength_id > 0:
- GLib.source_remove(self.strength_id)
- self.strength_id = 0
-
- def strength_cb(self, ignored):
- self._dbus_property_set(IFACE_WIMAX_NSP, PRP_WIMAX_NSP_SIGNAL_QUALITY, dbus.UInt32(random.randint(0, 100)))
- return True
-
@dbus.service.signal(IFACE_WIMAX_NSP, signature='a{sv}')
def PropertiesChanged(self, changed):
pass