summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2013-09-20 11:36:26 -0500
committerMartin Pitt <martinpitt@gnome.org>2013-09-20 11:59:37 -0500
commit6f9ccd35b3c1d154735e69064fda3ebee63cb2e0 (patch)
treeb00a7282070be6e680e380efaeac0ccf6fe4fa17
parent960d4413f93c1974166b55b15e8489f61e4485b6 (diff)
Linux integration tests: Test reconnect of bluetooth mouse
When these power down, we don't get remove uevents for the original power_supply devices from the kernel, but instead we get new devices with a different sequence number, but the same name: UDEV [6408.025124] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:12/0005:0D62:0558.0001/power_supply/hid-00:0f:f6:6d:8e:c0-battery (power_supply) UDEV [23785.90673] add /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:12/0005:0D62:0558.0002/power_supply/hid-00:0f:f6:6d:8e:c0-battery (power_supply) This circumvents the existing "treating add as change" check (as the native path is different) but breaks later on when building and registering the (supposedly) new object: ERROR **: Failed to register GObject with DBusConnection: org.freedesktop.DBus.Error.ObjectPathInUse A handler is already registered for /org/freedesktop/UPower/devices/mouse_hid_000ff66d8ec0_battery This reproduces https://launchpad.net/bugs/1112907
-rwxr-xr-xsrc/linux/integration-test70
1 files changed, 67 insertions, 3 deletions
diff --git a/src/linux/integration-test b/src/linux/integration-test
index 47773da..82b5ff7 100755
--- a/src/linux/integration-test
+++ b/src/linux/integration-test
@@ -574,8 +574,8 @@ class Tests(unittest.TestCase):
self.assertEqual(self.get_dbus_dev_property(bat0_up, 'Energy'), 1.5)
self.stop_daemon()
- def test_bluetooth_mouse(self):
- '''bluetooth mouse battery'''
+ def _add_bt_mouse(self):
+ '''Add a bluetooth mouse to testbed'''
btdev = self.testbed.add_device('bluetooth',
'usb1/bluetooth/hci0/hci0:01',
@@ -590,7 +590,7 @@ class Tests(unittest.TestCase):
mousebat0 = self.testbed.add_device(
'power_supply',
- 'usb1/bluetooth/hci0/hci0:01/power_supply/hid-00:11:22:33:44:55-battery',
+ 'usb1/bluetooth/hci0/hci0:01/1/power_supply/hid-00:11:22:33:44:55-battery',
None,
['type', 'Battery',
'scope', 'Device',
@@ -602,6 +602,13 @@ class Tests(unittest.TestCase):
],
[])
+ return mousebat0
+
+ def test_bluetooth_mouse(self):
+ '''bluetooth mouse battery'''
+
+ self._add_bt_mouse()
+
self.start_daemon()
devs = self.proxy.EnumerateDevices()
self.assertEqual(len(devs), 1)
@@ -616,6 +623,63 @@ class Tests(unittest.TestCase):
self.assertEqual(self.get_dbus_property('OnLowBattery'), False)
self.stop_daemon()
+ # https://launchpad.net/bugs/1112907
+ @unittest.expectedFailure
+ def test_bluetooth_mouse_reconnect(self):
+ '''bluetooth mouse powerdown/reconnect'''
+
+ mb = self._add_bt_mouse()
+
+ self.start_daemon()
+ devs_before = self.proxy.EnumerateDevices()
+ self.assertEqual(len(devs_before), 1)
+
+ self.testbed.uevent(mb, 'remove')
+ time.sleep(1)
+ self.assertEqual(self.proxy.EnumerateDevices(), [])
+ self.testbed.uevent(mb, 'add')
+ time.sleep(0.5)
+
+ devs_after = self.proxy.EnumerateDevices()
+ self.assertEqual(devs_before, devs_after)
+
+ # second add, which should be treated as change
+ self.testbed.uevent(mb, 'add')
+ time.sleep(0.5)
+
+ devs_after = self.proxy.EnumerateDevices()
+ self.assertEqual(devs_before, devs_after)
+
+ # with BT devices, original devices don't get removed on powerdown, but
+ # on wakeup we'll get a new one which ought to replace the previous;
+ # emulate that kernel bug
+ os.unlink(os.path.join(self.testbed.get_sys_dir(), 'class',
+ 'power_supply', 'hid-00:11:22:33:44:55-battery'))
+ mb1 = self.testbed.add_device(
+ 'power_supply',
+ 'usb1/bluetooth/hci0/hci0:01/2/power_supply/hid-00:11:22:33:44:55-battery',
+ None,
+ ['type', 'Battery',
+ 'scope', 'Device',
+ 'present', '1',
+ 'online', '1',
+ 'status', 'Discharging',
+ 'capacity', '30',
+ 'model_name', 'Fancy BT mouse',
+ ],
+ [])
+
+ self.testbed.uevent(mb1, 'add')
+ time.sleep(0.5)
+
+ devs_after = self.proxy.EnumerateDevices()
+ self.assertEqual(devs_before, devs_after)
+
+ mb1_up = devs_after[0]
+ self.assertEqual(self.get_dbus_dev_property(mb1_up, 'Model'), 'Fancy BT mouse')
+ self.assertEqual(self.get_dbus_dev_property(mb1_up, 'Percentage'), 30)
+ self.assertEqual(self.get_dbus_dev_property(mb1_up, 'PowerSupply'), False)
+
def test_bluetooth_keyboard(self):
'''bluetooth keyboard battery'''