Merge lp:~alan-griffiths/mir/in-process-server-test-fixture into lp:mir
- in-process-server-test-fixture
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1295 |
Proposed branch: | lp:~alan-griffiths/mir/in-process-server-test-fixture |
Merge into: | lp:mir |
Diff against target: |
217 lines (+174/-2) 4 files modified
include/test/mir_test_framework/in_process_server.h (+61/-0) tests/acceptance-tests/test_test_framework.cpp (+22/-2) tests/mir_test_framework/CMakeLists.txt (+1/-0) tests/mir_test_framework/in_process_server.cpp (+90/-0) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/in-process-server-test-fixture |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Chris Halse Rogers | Approve | ||
Daniel van Vugt | Approve | ||
Review via email: mp+198958@code.launchpad.net |
Commit message
tests: test fixture to run an in-process Mir server
Description of the change
tests: test fixture to run an in-process Mir server
I was really doing this to simplify testing message passing but, as we've changed direction I've split it out. It makes sense as a separate MP anyway.
PS Jenkins bot (ps-jenkins) wrote : | # |
Chris Halse Rogers (raof) wrote : | # |
You appear to have a half-finished tests/acceptanc
With that removed, looks good to me.
Daniel van Vugt (vanvugt) wrote : | # |
1. Aren't these two statements potentially in conflict?...
6 + * Copyright © 2013 Canonical Ltd.
20 + * Authored by: Alan Griffiths <email address hidden>
Should you be putting your Canonical email address there instead?
2. Local variable "display_server" masks member variable of the same name:
214 +mir::DisplaySe
If would be clearer to use a different name.
Alan Griffiths (alan-griffiths) wrote : | # |
> 1. Aren't these two statements potentially in conflict?...
> 6 + * Copyright © 2013 Canonical Ltd.
> 20 + * Authored by: Alan Griffiths <email address hidden>
> Should you be putting your Canonical email address there instead?
What's the conflict? I do this work for Octopull Limited and the copyright is assigned to Canonical Ltd.
> 2. Local variable "display_server" masks member variable of the same name:
> 214 +mir::DisplaySe
> If would be clearer to use a different name.
ack - fixed
Alan Griffiths (alan-griffiths) wrote : | # |
> You appear to have a half-finished tests/acceptance-
> tests/test_
>
> With that removed, looks good to me.
I don't think I can just remove it - as then there would be no test of this fixture. But I agree, the current version is misleading.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1290
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1291
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1291
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Alan Griffiths (alan-griffiths) wrote : | # |
Failure looks like a blip in the dependencies: re-approving
Daniel van Vugt (vanvugt) wrote : | # |
Why do we have "blips"?
Alan Griffiths (alan-griffiths) wrote : | # |
> Why do we have "blips"?
I don't know. But, if real, the errors reported should affect CI builds and other targets, not just autolanding.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Alan Griffiths (alan-griffiths) wrote : | # |
OK the blip was bug 1262305 - and that comes from a duff "partial chroot" setup that picked up some native system headers and the having a native g++4.8.2 vs armhf g++ g++4.8.1.
Re-approving now fix has landed
Chris Halse Rogers (raof) wrote : | # |
Hurray! No more stub test :)
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === added file 'include/test/mir_test_framework/in_process_server.h' |
2 | --- include/test/mir_test_framework/in_process_server.h 1970-01-01 00:00:00 +0000 |
3 | +++ include/test/mir_test_framework/in_process_server.h 2013-12-17 10:31:58 +0000 |
4 | @@ -0,0 +1,61 @@ |
5 | +/* |
6 | + * Copyright © 2013 Canonical Ltd. |
7 | + * |
8 | + * This program is free software: you can redistribute it and/or modify it |
9 | + * under the terms of the GNU General Public License version 3, |
10 | + * as published by the Free Software Foundation. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + * |
20 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
21 | + */ |
22 | + |
23 | +#ifndef MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_ |
24 | +#define MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_ |
25 | + |
26 | +#include <gtest/gtest.h> |
27 | + |
28 | +#include <string> |
29 | +#include <thread> |
30 | + |
31 | +namespace mir |
32 | +{ |
33 | +class DisplayServer; |
34 | +class DefaultServerConfiguration; |
35 | +} |
36 | + |
37 | + |
38 | +namespace mir_test_framework |
39 | +{ |
40 | +/// Fixture for running Mir server in test process |
41 | +struct InProcessServer : testing::Test |
42 | +{ |
43 | + ~InProcessServer(); |
44 | + |
45 | + /// Starts the server |
46 | + /// \warning don't forget to call this if you override SetUp() |
47 | + void SetUp() override; |
48 | + |
49 | + /// Stops the server |
50 | + /// \warning don't forget to call this if you override TearDown() |
51 | + void TearDown() override; |
52 | + |
53 | + /// \return a connection string for a new client to connect to the server |
54 | + std::string new_connection(); |
55 | + |
56 | +private: |
57 | + mir::DisplayServer* start_mir_server(); |
58 | + virtual mir::DefaultServerConfiguration& server_config() = 0; |
59 | + |
60 | + std::thread server_thread; |
61 | + mir::DisplayServer* display_server = 0; |
62 | +}; |
63 | +} |
64 | + |
65 | +#endif /* MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_ */ |
66 | |
67 | === modified file 'tests/acceptance-tests/test_test_framework.cpp' |
68 | --- tests/acceptance-tests/test_test_framework.cpp 2013-09-24 11:07:53 +0000 |
69 | +++ tests/acceptance-tests/test_test_framework.cpp 2013-12-17 10:31:58 +0000 |
70 | @@ -1,5 +1,5 @@ |
71 | /* |
72 | - * Copyright © 2012 Canonical Ltd. |
73 | + * Copyright © 2012, 2013 Canonical Ltd. |
74 | * |
75 | * This program is free software: you can redistribute it and/or modify |
76 | * it under the terms of the GNU General Public License version 3 as |
77 | @@ -17,8 +17,10 @@ |
78 | */ |
79 | |
80 | #include "mir_test_framework/display_server_test_fixture.h" |
81 | +#include "mir_test_framework/testing_server_configuration.h" |
82 | +#include "mir_test_framework/in_process_server.h" |
83 | |
84 | -#include "mir/frontend/connector.h" |
85 | +#include "mir_toolkit/mir_client_library.h" |
86 | |
87 | #include <gmock/gmock.h> |
88 | #include <gtest/gtest.h> |
89 | @@ -64,3 +66,21 @@ |
90 | launch_client_process(demo); |
91 | } |
92 | } |
93 | + |
94 | +namespace |
95 | +{ |
96 | +struct DemoInProcessServer : mir_test_framework::InProcessServer |
97 | +{ |
98 | + virtual mir::DefaultServerConfiguration& server_config() { return server_config_; } |
99 | + |
100 | + TestingServerConfiguration server_config_; |
101 | +}; |
102 | +} |
103 | + |
104 | +TEST_F(DemoInProcessServer, client_can_connect) |
105 | +{ |
106 | + auto const connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__); |
107 | + EXPECT_TRUE(mir_connection_is_valid(connection)); |
108 | + |
109 | + mir_connection_release(connection); |
110 | +} |
111 | |
112 | === modified file 'tests/mir_test_framework/CMakeLists.txt' |
113 | --- tests/mir_test_framework/CMakeLists.txt 2013-12-13 03:23:51 +0000 |
114 | +++ tests/mir_test_framework/CMakeLists.txt 2013-12-17 10:31:58 +0000 |
115 | @@ -10,6 +10,7 @@ |
116 | TEST_FRAMEWORK_SRCS |
117 | |
118 | cross_process_sync.cpp |
119 | + in_process_server.cpp |
120 | testing_server_options.cpp |
121 | input_testing_server_options.cpp |
122 | input_testing_client_configuration.cpp |
123 | |
124 | === added file 'tests/mir_test_framework/in_process_server.cpp' |
125 | --- tests/mir_test_framework/in_process_server.cpp 1970-01-01 00:00:00 +0000 |
126 | +++ tests/mir_test_framework/in_process_server.cpp 2013-12-17 10:31:58 +0000 |
127 | @@ -0,0 +1,90 @@ |
128 | +/* |
129 | + * Copyright © 2013 Canonical Ltd. |
130 | + * |
131 | + * This program is free software: you can redistribute it and/or modify it |
132 | + * under the terms of the GNU General Public License version 3, |
133 | + * as published by the Free Software Foundation. |
134 | + * |
135 | + * This program is distributed in the hope that it will be useful, |
136 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
137 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
138 | + * GNU General Public License for more details. |
139 | + * |
140 | + * You should have received a copy of the GNU General Public License |
141 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
142 | + * |
143 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
144 | + */ |
145 | + |
146 | +#include "mir_test_framework/in_process_server.h" |
147 | + |
148 | +#include "mir/default_server_configuration.h" |
149 | +#include "mir/display_server.h" |
150 | +#include "mir/frontend/connector.h" |
151 | +#include "mir/run_mir.h" |
152 | + |
153 | +#include <gtest/gtest.h> |
154 | + |
155 | +#include <condition_variable> |
156 | +#include <mutex> |
157 | + |
158 | +namespace mtf = mir_test_framework; |
159 | + |
160 | +void mtf::InProcessServer::SetUp() |
161 | +{ |
162 | + display_server = start_mir_server(); |
163 | + ASSERT_TRUE(display_server); |
164 | +} |
165 | + |
166 | +std::string mtf::InProcessServer::new_connection() |
167 | +{ |
168 | + char connect_string[64] = {0}; |
169 | + sprintf(connect_string, "fd://%d", server_config().the_connector()->client_socket_fd()); |
170 | + return connect_string; |
171 | +} |
172 | + |
173 | +void mtf::InProcessServer::TearDown() |
174 | +{ |
175 | + ASSERT_TRUE(display_server) |
176 | + << "Did you override SetUp() and forget to call mtf::InProcessServer::SetUp()?"; |
177 | + display_server->stop(); |
178 | +} |
179 | + |
180 | +mtf::InProcessServer::~InProcessServer() |
181 | +{ |
182 | + if (server_thread.joinable()) server_thread.join(); |
183 | +} |
184 | + |
185 | +mir::DisplayServer* mtf::InProcessServer::start_mir_server() |
186 | +{ |
187 | + std::mutex mutex; |
188 | + std::condition_variable cv; |
189 | + mir::DisplayServer* result{nullptr}; |
190 | + |
191 | + server_thread = std::thread([&] |
192 | + { |
193 | + try |
194 | + { |
195 | + mir::run_mir(server_config(), [&](mir::DisplayServer& ds) |
196 | + { |
197 | + std::unique_lock<std::mutex> lock(mutex); |
198 | + result = &ds; |
199 | + cv.notify_one(); |
200 | + }); |
201 | + } |
202 | + catch (std::exception const& e) |
203 | + { |
204 | + FAIL() << e.what(); |
205 | + } |
206 | + }); |
207 | + |
208 | + using namespace std::chrono; |
209 | + auto const time_limit = system_clock::now() + seconds(2); |
210 | + |
211 | + std::unique_lock<std::mutex> lock(mutex); |
212 | + |
213 | + while (!result && time_limit > system_clock::now()) |
214 | + cv.wait_until(lock, time_limit); |
215 | + |
216 | + return result; |
217 | +} |
FAILED: Continuous integration, rev:1289 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/534/ jenkins. qa.ubuntu. com/job/ mir-android- trusty- i386-build/ 433 jenkins. qa.ubuntu. com/job/ mir-clang- trusty- amd64-build/ 429 jenkins. qa.ubuntu. com/job/ mir-mediumtests -trusty- touch/39/ console jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 260 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 260/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 263 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 263/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- trusty- armhf/39 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- trusty- armhf/39/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/75/ console s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 2345
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- team-mir- development- branch- ci/534/ rebuild
http://