Mir

Merge lp:~alan-griffiths/mir/fix-1245336 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1177
Proposed branch: lp:~alan-griffiths/mir/fix-1245336
Merge into: lp:mir
Diff against target: 65 lines (+11/-6)
1 file modified
tests/acceptance-tests/test_server_shutdown.cpp (+11/-6)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1245336
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Robert Carr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+193093@code.launchpad.net

Commit message

Avoid a race condition that could lead to spurious failures of server
shutdown tests (LP: #1245336)

The race is between the acceptance-tests process and its child server process.
In our signal/abort tests, it's possible the server process may start and
stop so quickly that the parent process doesn't have time to detect the
socket file (before it's correctly cleaned up).

Description of the change

tests: Use CrossProcessSync to avoid race condition

Ensure that the test process has detected the endpoint on the filesystem before terminating the server

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
Robert Carr (robertcarr) wrote :

+1

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

Nice, thanks.

Simplicity is good. Though I notice the implementation of CrossProcessSync is actually much more complex than my proposed implementation. It looks like it could be more powerful too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_server_shutdown.cpp'
2--- tests/acceptance-tests/test_server_shutdown.cpp 2013-10-25 09:01:53 +0000
3+++ tests/acceptance-tests/test_server_shutdown.cpp 2013-10-29 16:38:44 +0000
4@@ -23,6 +23,7 @@
5
6 #include "mir_test_framework/display_server_test_fixture.h"
7 #include "mir_test/fake_event_hub_input_configuration.h"
8+#include "mir_test_framework/cross_process_sync.h"
9
10 #include <gtest/gtest.h>
11
12@@ -375,8 +376,11 @@
13 {
14 void exec() override
15 {
16+ sync.wait_for_signal_ready_for();
17 abort();
18 }
19+
20+ mtf::CrossProcessSync sync;
21 };
22
23 ServerConfig server_config;
24@@ -384,11 +388,10 @@
25
26 run_in_test_process([&]
27 {
28- using std::chrono::steady_clock;
29- std::chrono::seconds const limit(2);
30-
31 ASSERT_TRUE(file_exists(server_config.the_socket_file()));
32
33+ server_config.sync.signal_ready();
34+
35 // shutdown should fail as the server aborted
36 ASSERT_FALSE(shutdown_server_process());
37
38@@ -404,11 +407,14 @@
39 {
40 void exec() override
41 {
42+ sync.wait_for_signal_ready_for();
43 raise(sig);
44 }
45
46 ServerConfig(int sig) : sig(sig) {}
47+
48 int const sig;
49+ mtf::CrossProcessSync sync;
50 };
51
52 ServerConfig server_config(GetParam());
53@@ -416,11 +422,10 @@
54
55 run_in_test_process([&]
56 {
57- using std::chrono::steady_clock;
58- std::chrono::seconds const limit(2);
59-
60 ASSERT_TRUE(file_exists(server_config.the_socket_file()));
61
62+ server_config.sync.signal_ready();
63+
64 // shutdown should fail as the server faulted
65 ASSERT_FALSE(shutdown_server_process());
66

Subscribers

People subscribed via source and target branches