Mir

Merge lp:~vanvugt/mir/fix-1375211-v2 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1962
Proposed branch: lp:~vanvugt/mir/fix-1375211-v2
Merge into: lp:mir
Diff against target: 15 lines (+4/-1)
1 file modified
src/common/input/android/android_input_receiver.cpp (+4/-1)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1375211-v2
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+236989@code.launchpad.net

Commit message

Fix input receiver tests with mocked clocks accidentally taking real
time (not mocked time) to complete (LP: #1375211)

Description of the change

Version 2: This one is more tolerant of CI glitches and slowdowns, which should avoid spurious test failures.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

24 +TEST_F(AndroidInputReceiverSetup, zero_timeout_is_less_than_1ms)

More robust than the last version, but still somewhat fragile. Let's see if this does the trick for CI/autolanding. Hopefully we will be able to properly mock time in the input subsystem in the future.

49 if (!is_sometimes_less_than_1ms &&
50 + duration < std::chrono::milliseconds(1))
51 + is_sometimes_less_than_1ms = true;

Could be "is_sometimes_less_than_1ms |= (duration < std::chrono::milliseconds(1));"

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Making the test less likely to fail doesn't make it completely reliable.

I'm not convinced that the test is testing anything that we can (or need) to guarantee - can we just get rid of it?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yeah my original fix had no test. But I like the idea of having some regression test. Especially since I've messed it up in the past.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Yeah my original fix had no test. But I like the idea of having some
> regression test. Especially since I've messed it up in the past.

I understand the desire to validate but this specific test is effectively testing that the code runs "fast enough" on the test machine. With unpredictable loads, valgrind and slow hardware this has to be uncertain.

We don't need many tests that "work 99.9% of the time" to create annoying problems. (It has cost us time to identify and eliminate ones that have crept in previously and we don't need to let more in.)

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fixed, per Alan's request.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Still OK.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common/input/android/android_input_receiver.cpp'
2--- src/common/input/android/android_input_receiver.cpp 2014-10-03 03:02:09 +0000
3+++ src/common/input/android/android_input_receiver.cpp 2014-10-06 03:05:53 +0000
4@@ -153,7 +153,10 @@
5 // But the batch won't get flushed until the next frame interval,
6 // so be sure to use a non-zero sleep time to avoid spinning the CPU
7 // for the whole interval...
8- reduced_timeout = std::chrono::milliseconds(1);
9+
10+ // During tests with mocked clocks we may already have zero...
11+ if (reduced_timeout != std::chrono::milliseconds::zero())
12+ reduced_timeout = std::chrono::milliseconds(1);
13 }
14
15 auto result = looper->pollOnce(reduced_timeout.count());

Subscribers

People subscribed via source and target branches