Merge lp:~aacid/autopilot/precreate_keyboard into lp:autopilot

Proposed by Albert Astals Cid
Status: Merged
Approved by: Christopher Lee
Approved revision: 549
Merged at revision: 549
Proposed branch: lp:~aacid/autopilot/precreate_keyboard
Merge into: lp:autopilot
Diff against target: 22 lines (+1/-3)
1 file modified
autopilot/testcase.py (+1/-3)
To merge this branch: bzr merge lp:~aacid/autopilot/precreate_keyboard
Reviewer Review Type Date Requested Status
Christopher Lee (community) Approve
PS Jenkins bot continuous-integration Approve
Nick Dedekind (community) Needs Information
Review via email: mp+254095@code.launchpad.net

Commit message

Create keyboard well before it's going to be used

Otherwise it can cause races when using the uinput keyboard in mir, e.g.

    Mir log says
      [1427285878.342107] android-input: [EventHub]New device: id=18, fd=66, path='/dev/input/event8', name='py-evdev-uinput', classes=0x80000063, configuration='', keyLayout='Generic.kl', keyCharacterMap='Generic.kcm', builtinKeyboard=false, usingSuspendBlockIoctl=true, usingClockIoctl=true

    autopilot log says
      12:17:58.305 DEBUG _uinput:60 - Pressing p (25).

25 March 2015 12:17:58.305 is 1427285878.305, that is, the key press is sent 37 milliseconds before mir sees the device, so that key press is lost

Description of the change

Fix unstable unity8.shell.tests.test_lock_screen.TestLockscreen.test_can_unlock_passphrase_screen test

Autopilot 1.5 version at https://code.launchpad.net/~aacid/autopilot/precreate_keyboard15/+merge/254209

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Hm. would a better solution not to be waiting for it to be ready before using it?
ie. wait for Keyboard.visible=True before pressing a key?

See the osk focused_type method. It uses a wait_for_keyboard_ready() call, although not sure why it's not always used.

review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

There's nothing to wait for, this is not the OSK, it's a uinput based keyboard that just injects events directly into the kernel (or some very low level layer) by writing into a file in /dev

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:549
http://jenkins.qa.ubuntu.com/job/autopilot-ci/1032/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/95
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/95/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/95
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/95/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/95
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/95/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/1966
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-vivid-autopilot/140
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/1733
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1964
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1964/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/19148
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-vivid-autopilot/142
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/891
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/891/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/autopilot-ci/1032/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Lee (veebers) wrote :

Can we confirm that creating the Keyboard at setUp() will always be in time for mir? (i.e. is it possible that even then it's not early enough).

If we can then this looks good to me. Otherwise there needs to be a more solid solution.

review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

I can not guarantee it but i have tested it and seems that the 50% failure rate we had is gone

Also we do some more stuff in setUp() that will delay the earliest use of the keyboard by the testcase itself, probably giving mir time to catch up.

Which is basically the same _ensure_uinput_device_created() is doing on the next line.

Other than adding a big random sleep() somewhere i don't see how we can actually guarantee Mir will have seen the device.

Other Ideas?

Revision history for this message
Christopher Lee (veebers) wrote :

In that case this is all good. LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/testcase.py'
2--- autopilot/testcase.py 2014-09-05 04:58:58 +0000
3+++ autopilot/testcase.py 2015-03-25 14:24:11 +0000
4@@ -161,8 +161,8 @@
5
6 self._process_manager = None
7 self._mouse = None
8- self._kb = None
9 self._display = None
10+ self._kb = Keyboard.create()
11
12 # Work around for bug lp:1297592.
13 _ensure_uinput_device_created()
14@@ -185,8 +185,6 @@
15
16 @property
17 def keyboard(self):
18- if self._kb is None:
19- self._kb = Keyboard.create()
20 return self._kb
21
22 @property

Subscribers

People subscribed via source and target branches