Mir

Merge lp:~alan-griffiths/mir/fix-1388802-possibly into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2040
Proposed branch: lp:~alan-griffiths/mir/fix-1388802-possibly
Merge into: lp:mir
Diff against target: 132 lines (+33/-3)
1 file modified
tests/acceptance-tests/test_client_input.cpp (+33/-3)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1388802-possibly
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Alberto Aguirre (community) Approve
Review via email: mp+240926@code.launchpad.net

Commit message

tests: Make TestClientInput less helgrind unfriendly

Description of the change

tests: Make TestClientInput less helgrind unfriendly

helgrind reports a number of errors around expectations - but many of these seem to be because the thread fulfilling the expectation is running before the expectation is set. There is sequencing (by only sending events from the server after setting expectations) but streaming data over a socket goes beyond the "memory model" and helgrind doesn't see it.

I've changed the tests to start the client thread after the expectations are set - which more than halves the size of the helgrind report.

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
Alberto Aguirre (albaguirre) wrote :

Sure.

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

I'm not super-enthused about the general principle of making code (slightly) less obviously correct in order to appease an external correctness-checking tool.

In this case it seems a worthwhile tradeoff.

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

Suspicious that acceptance tests for this are crashing in CI. That suggests more needs fixing...

pull: /var/crash/_usr_bin_mir_acceptance_tests.32011.uploaded -> ./results/crash/_usr_bin_mir_acceptance_tests.32011.uploaded
failed to copy '/var/crash/_usr_bin_mir_acceptance_tests.32011.uploaded' to './results/crash/_usr_bin_mir_acceptance_tests.32011.uploaded': Permission denied
pull: /var/crash/_usr_bin_mir_acceptance_tests.32011.upload -> ./results/crash/_usr_bin_mir_acceptance_tests.32011.upload
pull: /var/crash/_usr_sbin_unity-system-compositor.0.uploaded -> ./results/crash/_usr_sbin_unity-system-compositor.0.uploaded
failed to copy '/var/crash/_usr_sbin_unity-system-compositor.0.uploaded' to './results/crash/_usr_sbin_unity-system-compositor.0.uploaded': Permission denied
pull: /var/crash/_usr_sbin_unity-system-compositor.0.upload -> ./results/crash/_usr_sbin_unity-system-compositor.0.upload
pull: /var/crash/_usr_bin_mir_acceptance_tests.32011.crash -> ./results/crash/_usr_bin_mir_acceptance_tests.32011.crash
pull: /var/crash/_usr_sbin_unity-system-compositor.0.crash -> ./results/crash/_usr_sbin_unity-system-compositor.0.crash
failed to copy '/var/crash/_usr_sbin_unity-system-compositor.0.crash' to './results/crash/_usr_sbin_unity-system-compositor.0.crash': Permission denied
pull: /var/crash/.lock -> ./results/crash/.lock
7 files pulled. 0 files skipped.

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

The failing test is unrelated to this MP:

[----------] 1 test from StaleFrames
[ RUN ] StaleFrames.are_dropped_when_restarting_compositor
/tmp/buildd/mir-0.8.0+14.10.20141010bzr2039pkg0vivid4+autopilot0/tests/integration-tests/test_stale_frames.cpp:203: Failure
Expected: (stale_buffer_id1) != (stale_buffer_id2), actual: 3 vs 3
/tmp/buildd/mir-0.8.0+14.10.20141010bzr2039pkg0vivid4+autopilot0/tests/integration-tests/test_stale_frames.cpp:204: Failure
Expected: (stale_buffer_id2) != (buffer_id3), actual: 3 vs 3
/tmp/buildd/mir-0.8.0+14.10.20141010bzr2039pkg0vivid4+autopilot0/tests/integration-tests/test_stale_frames.cpp:209: Failure
Value of: new_buffers[0]
Actual: 40
Expected: buffer_id3
Which is: 3
[ FAILED ] StaleFrames.are_dropped_when_restarting_compositor (221 ms)

I guess that needs a bug of its own: lp:1390388

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

(Re-triggering to see what jobs run and what tests fail)

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_client_input.cpp'
2--- tests/acceptance-tests/test_client_input.cpp 2014-10-21 16:21:14 +0000
3+++ tests/acceptance-tests/test_client_input.cpp 2014-11-06 17:29:14 +0000
4@@ -60,18 +60,23 @@
5 struct InputClient
6 {
7 InputClient(std::string const& connect_string, std::string const& client_name)
8- : connect_string{connect_string}, client_name{client_name},
9- client_thread{[this] { run(); }}
10+ : connect_string{connect_string}, client_name{client_name}
11 {
12- ready_to_accept_events.wait_for_at_most_seconds(5);
13 }
14
15+
16 ~InputClient()
17 {
18 if (client_thread.joinable())
19 client_thread.join();
20 }
21
22+ void start()
23+ {
24+ client_thread = std::thread{[this] { run(); }};
25+ ready_to_accept_events.wait_for_at_most_seconds(5);
26+ }
27+
28 void run()
29 {
30 auto const connection =
31@@ -231,6 +236,8 @@
32
33 int const num_events_produced = 3;
34
35+ client.start();
36+
37 for (int i = 0; i < num_events_produced; i++)
38 fake_event_hub()->synthesize_event(
39 mis::a_key_down_event().of_scancode(KEY_ENTER));
40@@ -252,6 +259,8 @@
41 AllOf(mt::KeyDownEvent(), mt::KeyOfSymbol(XKB_KEY_dollar))))
42 .WillOnce(mt::WakeUp(&client.all_events_received));
43
44+ client.start();
45+
46 fake_event_hub()->synthesize_event(
47 mis::a_key_down_event().of_scancode(KEY_LEFTSHIFT));
48 fake_event_hub()->synthesize_event(
49@@ -276,6 +285,8 @@
50 .WillOnce(mt::WakeUp(&client.all_events_received));
51 // But we should not receive an event for the second movement outside of our surface!
52
53+ client.start();
54+
55 fake_event_hub()->synthesize_event(
56 mis::a_motion_event().with_movement(
57 InputClient::surface_width - 1,
58@@ -293,6 +304,8 @@
59 EXPECT_CALL(client.handler, handle_input(mt::ButtonDownEvent(0, 0)))
60 .WillOnce(mt::WakeUp(&client.all_events_received));
61
62+ client.start();
63+
64 fake_event_hub()->synthesize_event(
65 mis::a_button_down_event()
66 .of_button(BTN_LEFT)
67@@ -335,6 +348,9 @@
68 .WillOnce(mt::WakeUp(&client2.all_events_received));
69 }
70
71+ client1.start();
72+ client2.start();
73+
74 // In the bounds of the first surface
75 fake_event_hub()->synthesize_event(
76 mis::a_motion_event().with_movement(screen_width / 2 - 1, screen_height / 2 - 1));
77@@ -370,6 +386,8 @@
78 .WillOnce(mt::WakeUp(&client.all_events_received));
79 }
80
81+ client.start();
82+
83 // First we will move the cursor in to the input region on the left side of
84 // the window. We should see a click here.
85 fake_event_hub()->synthesize_event(mis::a_motion_event().with_movement(1, 1));
86@@ -434,6 +452,9 @@
87 .WillOnce(mt::WakeUp(&client2.all_events_received));
88 }
89
90+ client1.start();
91+ client2.start();
92+
93 // First we will move the cursor in to the region where client 2 obscures client 1
94 fake_event_hub()->synthesize_event(mis::a_motion_event().with_movement(1, 1));
95 fake_event_hub()->synthesize_event(
96@@ -469,6 +490,9 @@
97 .WillOnce(DoAll(mt::WakeUp(&second_client_done),
98 mt::WakeUp(&client2.all_events_received)));
99
100+ client1.start();
101+ client2.start();
102+
103 // We send one event and then hide the surface on top before sending the next.
104 // So we expect each of the two surfaces to receive one even
105 fake_event_hub()->synthesize_event(mis::a_motion_event().with_movement(1,1));
106@@ -506,6 +530,8 @@
107 .Times(AnyNumber())
108 .WillOnce(mt::WakeUp(&client1.all_events_received));
109
110+ client1.start();
111+
112 server_config().the_session_container()->for_each(
113 [&](std::shared_ptr<ms::Session> const& session) -> void
114 {
115@@ -559,6 +585,8 @@
116 expected_motion_y_2)))
117 .WillOnce(mt::WakeUp(&client1.all_events_received));
118
119+ client1.start();
120+
121 fake_event_hub()->synthesize_event(
122 mis::a_touch_event().at_position({abs_touch_x_1, abs_touch_y_1}));
123 // Sleep here to trigger more failures (simulate slow machine)
124@@ -574,6 +602,8 @@
125 EXPECT_CALL(client1.handler, handle_input(mt::KeyDownEvent()))
126 .WillOnce(mt::WakeUp(&client1.all_events_received));
127
128+ client1.start();
129+
130 server_config().the_session_container()->for_each(
131 [] (std::shared_ptr<ms::Session> const& session) -> void
132 {

Subscribers

People subscribed via source and target branches