From ec39498fc6d70cf6887f08b4dfbc5cff021fc231 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 31 Oct 2019 16:38:36 +0100 Subject: [PATCH] tests: support D-Bus property Device.StateReason in mock service The device interface (org.freedesktop.NetworkManager.Device) has two properties: "State" and "StateReason". Both of them are supported by NetworkManager for a very long time. Note that "StateReason" is a tuple and also exposes the state along the reason. When reworking libnm, we will ignore the "State" property and only consider "StateReason". The advantage is less code and not using redundant state. This will also work well, because NetworkManager's D-Bus API supports this property for a very long time. However, that would then break the CI tests, because currently "tools/test-networkmanager-service.py" does not expose that property. Add it. --- tools/test-networkmanager-service.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 19d4baef2c..e91b45233e 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -672,6 +672,7 @@ PRP_DEVICE_UDI = "Udi" PRP_DEVICE_IFACE = "Interface" PRP_DEVICE_DRIVER = "Driver" PRP_DEVICE_STATE = "State" +PRP_DEVICE_STATE_REASON = "StateReason" PRP_DEVICE_ACTIVE_CONNECTION = "ActiveConnection" PRP_DEVICE_IP4_CONFIG = "Ip4Config" PRP_DEVICE_IP6_CONFIG = "Ip6Config" @@ -700,11 +701,14 @@ class Device(ExportedObj): self.dhcp4_config = None self.dhcp6_config = None + self.prp_state = NM.DeviceState.UNAVAILABLE + props = { PRP_DEVICE_UDI: "/sys/devices/virtual/%s" % (iface), PRP_DEVICE_IFACE: iface, PRP_DEVICE_DRIVER: "virtual", - PRP_DEVICE_STATE: dbus.UInt32(NM.DeviceState.UNAVAILABLE), + PRP_DEVICE_STATE: dbus.UInt32(self.prp_state), + PRP_DEVICE_STATE_REASON: dbus.Struct((dbus.UInt32(self.prp_state), dbus.UInt32(NM.DeviceStateReason.NONE))), PRP_DEVICE_ACTIVE_CONNECTION: ExportedObj.to_path(None), PRP_DEVICE_IP4_CONFIG: ExportedObj.to_path(self.ip4_config), PRP_DEVICE_IP6_CONFIG: ExportedObj.to_path(self.ip6_config),