Merge lp:~alan-griffiths/mir/migrate-more-acceptances-tests into lp:mir
- migrate-more-acceptances-tests
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Cemil Azizoglu |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2073 |
Proposed branch: | lp:~alan-griffiths/mir/migrate-more-acceptances-tests |
Merge into: | lp:mir |
Diff against target: |
772 lines (+303/-256) 9 files modified
tests/acceptance-tests/test_client_library_errors.cpp (+3/-13) tests/acceptance-tests/test_client_surface_events.cpp (+26/-35) tests/acceptance-tests/test_client_surface_swap_buffers.cpp (+2/-30) tests/acceptance-tests/test_server_disconnect.cpp (+148/-172) tests/include/mir_test_framework/connected_client_with_a_surface.h (+36/-0) tests/include/mir_test_framework/interprocess_client_server_test.h (+7/-0) tests/mir_test_framework/CMakeLists.txt (+1/-0) tests/mir_test_framework/connected_client_with_a_surface.cpp (+44/-0) tests/mir_test_framework/interprocess_client_server_test.cpp (+36/-6) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/migrate-more-acceptances-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Cemil Azizoglu (community) | Approve | ||
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+242094@code.launchpad.net |
Commit message
tests: migrate some more acceptance tests to the mir::Server API
Description of the change
tests: migrate some more acceptance tests to the mir::Server API
I think this covers all the tests that cam be trivially reworked.
The remaining tests customize functionality for which there is no longer a customization point. (E.g. faking the event hub, customizing the display configuration within the stubbed graphics, or other classes that DefaultServerCo
I'm going to work on proposing those individually as there are decisions (and potential discussion) needed about what should be a supported customization point and how it should be made available.
PS Jenkins bot (ps-jenkins) wrote : | # |
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Alan Griffiths (alan-griffiths) wrote : | # |
RUN ] MesaBufferAlloc
unknown file: Failure
C++ exception with description "Failed to open temporary file" thrown in the test body.
[ FAILED ] MesaBufferAlloc
...
[ RUN ] MesaBufferAlloc
unknown file: Failure
C++ exception with description "Failed to open temporary file" thrown in the test body.
[ FAILED ] MesaBufferAlloc
...
[ RUN ] AnonymousShmFil
unknown file: Failure
C++ exception with description "Failed to open temporary file" thrown in the test body.
[ FAILED ] AnonymousShmFil
[ RUN ] AnonymousShmFil
unknown file: Failure
C++ exception with description "Failed to open temporary file" thrown in the test body.
[ FAILED ] AnonymousShmFil
IIRC these tests fail on CI's old kernel and should be filtered. Investigating...
Alan Griffiths (alan-griffiths) wrote : | # |
> IIRC these tests fail on CI's old kernel and should be filtered.
> Investigating...
cmake/MirCommon
# Some tests expect kernel version 3.11 and up
if (${KERNEL_VERSION} VERSION_LESS "3.11")
From the failing console: "-- Kernel version detected: 3.13"
So we should be running the tests (and they ought to be passing).
Alan Griffiths (alan-griffiths) wrote : | # |
And 3.13 worked here: https:/
Re-approving
Alan Griffiths (alan-griffiths) wrote : | # |
Logged as lp:1394278
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
fginther disabled the host where tests have failed. Apparently it was a machine that was a newly created cloud instance. He is to follow up and root-cause it on his side. He suggested we re-TA.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2078
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'tests/acceptance-tests/test_client_library_errors.cpp' |
2 | --- tests/acceptance-tests/test_client_library_errors.cpp 2014-11-05 10:17:05 +0000 |
3 | +++ tests/acceptance-tests/test_client_library_errors.cpp 2014-11-18 16:56:14 +0000 |
4 | @@ -25,8 +25,7 @@ |
5 | |
6 | #include "mir_test/validity_matchers.h" |
7 | |
8 | -#include "mir_test_framework/in_process_server.h" |
9 | -#include "mir_test_framework/stubbed_server_configuration.h" |
10 | +#include "mir_test_framework/headless_in_process_server.h" |
11 | #include "mir_test_framework/using_stub_client_platform.h" |
12 | #include "mir_test_framework/stub_client_connection_configuration.h" |
13 | |
14 | @@ -132,19 +131,10 @@ |
15 | return std::make_shared<ConfigurableFailureFactory<failure_set>>(); |
16 | } |
17 | }; |
18 | - |
19 | -class ClientLibraryErrors : public mtf::InProcessServer |
20 | -{ |
21 | -private: |
22 | - mtf::StubbedServerConfiguration config; |
23 | - |
24 | - mir::DefaultServerConfiguration &server_config() override |
25 | - { |
26 | - return config; |
27 | - } |
28 | -}; |
29 | } |
30 | |
31 | +using ClientLibraryErrors = mtf::HeadlessInProcessServer; |
32 | + |
33 | TEST_F(ClientLibraryErrors, exception_in_client_configuration_constructor_generates_error) |
34 | { |
35 | mtf::UsingClientPlatform<ConfigurableFailureConfiguration<Method::the_client_platform_factory>> stubby; |
36 | |
37 | === modified file 'tests/acceptance-tests/test_client_surface_events.cpp' |
38 | --- tests/acceptance-tests/test_client_surface_events.cpp 2014-10-27 22:31:16 +0000 |
39 | +++ tests/acceptance-tests/test_client_surface_events.cpp 2014-11-18 16:56:14 +0000 |
40 | @@ -24,8 +24,7 @@ |
41 | #include "mir/scene/surface.h" |
42 | #include "mir/scene/surface_creation_parameters.h" |
43 | |
44 | -#include "mir_test_framework/stubbed_server_configuration.h" |
45 | -#include "mir_test_framework/basic_client_server_fixture.h" |
46 | +#include "mir_test_framework/connected_client_with_a_surface.h" |
47 | |
48 | #include <gtest/gtest.h> |
49 | #include <gmock/gmock.h> |
50 | @@ -60,32 +59,7 @@ |
51 | std::shared_ptr<ms::Surface> latest_surface; |
52 | }; |
53 | |
54 | -struct MyConfig : mtf::StubbedServerConfiguration |
55 | -{ |
56 | - std::shared_ptr<ms::SurfaceCoordinator> wrap_surface_coordinator( |
57 | - std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) override |
58 | - { |
59 | - auto const msc = std::make_shared<MockSurfaceCoordinator>(wrapped); |
60 | - mock_surface_coordinator = msc; |
61 | - return msc; |
62 | - } |
63 | - |
64 | - std::shared_ptr<MockSurfaceCoordinator> the_mock_surface_coordinator() const |
65 | - { |
66 | - return mock_surface_coordinator.lock(); |
67 | - } |
68 | - |
69 | - std::shared_ptr<ms::Surface> the_latest_surface() const |
70 | - { |
71 | - return the_mock_surface_coordinator()->latest_surface; |
72 | - } |
73 | - |
74 | - std::weak_ptr<MockSurfaceCoordinator> mock_surface_coordinator; |
75 | -}; |
76 | - |
77 | -using BasicClientServerFixture = mtf::BasicClientServerFixture<MyConfig>; |
78 | - |
79 | -struct ClientSurfaceEvents : BasicClientServerFixture |
80 | +struct ClientSurfaceEvents : mtf::ConnectedClientWithASurface |
81 | { |
82 | MirSurfaceParameters const request_params |
83 | { |
84 | @@ -96,7 +70,6 @@ |
85 | mir_display_output_id_invalid |
86 | }; |
87 | |
88 | - MirSurface* surface{nullptr}; |
89 | MirSurface* other_surface; |
90 | |
91 | std::mutex last_event_mutex; |
92 | @@ -139,14 +112,31 @@ |
93 | last_event_surface = nullptr; |
94 | } |
95 | |
96 | + std::shared_ptr<MockSurfaceCoordinator> the_mock_surface_coordinator() const |
97 | + { |
98 | + return mock_surface_coordinator.lock(); |
99 | + } |
100 | + |
101 | + std::shared_ptr<ms::Surface> the_latest_surface() const |
102 | + { |
103 | + return the_mock_surface_coordinator()->latest_surface; |
104 | + } |
105 | + |
106 | void SetUp() override |
107 | { |
108 | - BasicClientServerFixture::SetUp(); |
109 | - |
110 | - surface = mir_connection_create_surface_sync(connection, &request_params); |
111 | + server.wrap_surface_coordinator([&](std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) |
112 | + -> std::shared_ptr<ms::SurfaceCoordinator> |
113 | + { |
114 | + auto const msc = std::make_shared<MockSurfaceCoordinator>(wrapped); |
115 | + mock_surface_coordinator = msc; |
116 | + return msc; |
117 | + }); |
118 | + |
119 | + mtf::ConnectedClientWithASurface::SetUp(); |
120 | + |
121 | mir_surface_set_event_handler(surface, &delegate); |
122 | |
123 | - scene_surface = server_configuration.the_latest_surface(); |
124 | + scene_surface = the_latest_surface(); |
125 | |
126 | other_surface = mir_connection_create_surface_sync(connection, &request_params); |
127 | mir_surface_set_event_handler(other_surface, nullptr); |
128 | @@ -158,10 +148,11 @@ |
129 | { |
130 | mir_surface_release_sync(other_surface); |
131 | scene_surface.reset(); |
132 | - mir_surface_release_sync(surface); |
133 | |
134 | - BasicClientServerFixture::TearDown(); |
135 | + mtf::ConnectedClientWithASurface::TearDown(); |
136 | } |
137 | + |
138 | + std::weak_ptr<MockSurfaceCoordinator> mock_surface_coordinator; |
139 | }; |
140 | } |
141 | |
142 | |
143 | === modified file 'tests/acceptance-tests/test_client_surface_swap_buffers.cpp' |
144 | --- tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2014-11-18 03:21:20 +0000 |
145 | +++ tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2014-11-18 16:56:14 +0000 |
146 | @@ -18,7 +18,7 @@ |
147 | |
148 | #include "mir_toolkit/mir_client_library.h" |
149 | |
150 | -#include "mir_test_framework/connected_client_headless_server.h" |
151 | +#include "mir_test_framework/connected_client_with_a_surface.h" |
152 | #include "mir_test_doubles/null_display_buffer_compositor_factory.h" |
153 | #include "mir_test/signal.h" |
154 | |
155 | @@ -38,35 +38,7 @@ |
156 | buffers_swapped->raise(); |
157 | } |
158 | |
159 | -struct ConnectedClientWithASurface : mtf::ConnectedClientHeadlessServer |
160 | -{ |
161 | - MirSurface* surface{nullptr}; |
162 | - |
163 | - void SetUp() override |
164 | - { |
165 | - mtf::ConnectedClientHeadlessServer::SetUp(); |
166 | - |
167 | - MirSurfaceParameters request_params = |
168 | - { |
169 | - __PRETTY_FUNCTION__, |
170 | - 640, 480, |
171 | - mir_pixel_format_abgr_8888, |
172 | - mir_buffer_usage_hardware, |
173 | - mir_display_output_id_invalid |
174 | - }; |
175 | - |
176 | - surface = mir_connection_create_surface_sync(connection, &request_params); |
177 | - ASSERT_TRUE(mir_surface_is_valid(surface)); |
178 | - } |
179 | - |
180 | - void TearDown() override |
181 | - { |
182 | - mir_surface_release_sync(surface); |
183 | - mtf::ConnectedClientHeadlessServer::TearDown(); |
184 | - } |
185 | -}; |
186 | - |
187 | -struct SurfaceSwapBuffers : ConnectedClientWithASurface |
188 | +struct SurfaceSwapBuffers : mtf::ConnectedClientWithASurface |
189 | { |
190 | void SetUp() override |
191 | { |
192 | |
193 | === modified file 'tests/acceptance-tests/test_server_disconnect.cpp' |
194 | --- tests/acceptance-tests/test_server_disconnect.cpp 2014-11-11 15:50:11 +0000 |
195 | +++ tests/acceptance-tests/test_server_disconnect.cpp 2014-11-18 16:56:14 +0000 |
196 | @@ -18,8 +18,9 @@ |
197 | |
198 | #include "mir_toolkit/mir_client_library.h" |
199 | |
200 | -#include "mir_test_framework/display_server_test_fixture.h" |
201 | +#include "mir_test_framework/interprocess_client_server_test.h" |
202 | #include "mir_test_framework/cross_process_sync.h" |
203 | +#include "mir_test_framework/process.h" |
204 | #include "mir_test/cross_process_action.h" |
205 | |
206 | #include <gtest/gtest.h> |
207 | @@ -30,10 +31,17 @@ |
208 | namespace mtf = mir_test_framework; |
209 | namespace mt = mir::test; |
210 | |
211 | -using ServerDisconnect = mtf::BespokeDisplayServerTestFixture; |
212 | - |
213 | namespace |
214 | { |
215 | +struct ServerDisconnect : mtf::InterprocessClientServerTest |
216 | +{ |
217 | + void SetUp() override |
218 | + { |
219 | + mtf::InterprocessClientServerTest::SetUp(); |
220 | + run_in_server([]{}); |
221 | + } |
222 | +}; |
223 | + |
224 | struct MockEventHandler |
225 | { |
226 | MOCK_METHOD1(handle, void(MirLifecycleState transition)); |
227 | @@ -44,61 +52,132 @@ |
228 | } |
229 | }; |
230 | |
231 | -struct MyTestingClientConfiguration : mtf::TestingClientConfiguration |
232 | -{ |
233 | - void exec() override |
234 | - { |
235 | - static MirSurfaceParameters const params = |
236 | - { __PRETTY_FUNCTION__, 33, 45, mir_pixel_format_abgr_8888, |
237 | - mir_buffer_usage_hardware, mir_display_output_id_invalid }; |
238 | - |
239 | - MockEventHandler mock_event_handler; |
240 | - |
241 | - auto connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
242 | - mir_connection_set_lifecycle_event_callback(connection, &MockEventHandler::handle, &mock_event_handler); |
243 | - auto surface = mir_connection_create_surface_sync(connection, ¶ms); |
244 | - |
245 | - std::atomic<bool> signalled(false); |
246 | - |
247 | - EXPECT_CALL(mock_event_handler, handle(mir_lifecycle_connection_lost)).Times(1). |
248 | - WillOnce(testing::InvokeWithoutArgs([&] { signalled.store(true); })); |
249 | - |
250 | - sync.signal_ready(); |
251 | - |
252 | - using clock = std::chrono::high_resolution_clock; |
253 | - |
254 | - auto time_limit = clock::now() + std::chrono::seconds(2); |
255 | - |
256 | - while (!signalled.load() && clock::now() < time_limit) |
257 | - { |
258 | - mir_surface_swap_buffers_sync(surface); |
259 | - } |
260 | - mir_surface_release_sync(surface); |
261 | - mir_connection_release(connection); |
262 | - } |
263 | - |
264 | +void null_lifecycle_callback(MirConnection*, MirLifecycleState, void*) |
265 | +{ |
266 | +} |
267 | +} |
268 | + |
269 | +TEST_F(ServerDisconnect, is_detected_by_client) |
270 | +{ |
271 | mtf::CrossProcessSync sync; |
272 | -}; |
273 | - |
274 | -struct DisconnectingTestingClientConfiguration : mtf::TestingClientConfiguration |
275 | -{ |
276 | - void exec() override |
277 | - { |
278 | - MirConnection* connection{nullptr}; |
279 | - |
280 | - connect.exec([&] { |
281 | - connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
282 | - EXPECT_TRUE(mir_connection_is_valid(connection)); |
283 | - /* |
284 | - * Set a null callback to avoid killing the process |
285 | - * (default callback raises SIGHUP). |
286 | - */ |
287 | - mir_connection_set_lifecycle_event_callback(connection, |
288 | - null_lifecycle_callback, |
289 | - nullptr); |
290 | - }); |
291 | - |
292 | - create_surface.exec([&] { |
293 | + |
294 | + auto const client = new_client_process([&] |
295 | + { |
296 | + static MirSurfaceParameters const params = |
297 | + { __PRETTY_FUNCTION__, 33, 45, mir_pixel_format_abgr_8888, |
298 | + mir_buffer_usage_hardware, mir_display_output_id_invalid }; |
299 | + |
300 | + MockEventHandler mock_event_handler; |
301 | + |
302 | + auto connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
303 | + mir_connection_set_lifecycle_event_callback(connection, &MockEventHandler::handle, &mock_event_handler); |
304 | + auto surface = mir_connection_create_surface_sync(connection, ¶ms); |
305 | + |
306 | + std::atomic<bool> signalled(false); |
307 | + |
308 | + EXPECT_CALL(mock_event_handler, handle(mir_lifecycle_connection_lost)).Times(1). |
309 | + WillOnce(testing::InvokeWithoutArgs([&] { signalled.store(true); })); |
310 | + |
311 | + sync.signal_ready(); |
312 | + |
313 | + using clock = std::chrono::high_resolution_clock; |
314 | + |
315 | + auto time_limit = clock::now() + std::chrono::seconds(2); |
316 | + |
317 | + while (!signalled.load() && clock::now() < time_limit) |
318 | + { |
319 | + mir_surface_swap_buffers_sync(surface); |
320 | + } |
321 | + mir_surface_release_sync(surface); |
322 | + mir_connection_release(connection); |
323 | + }); |
324 | + |
325 | + if (is_test_process()) |
326 | + { |
327 | + sync.wait_for_signal_ready_for(); |
328 | + stop_server(); |
329 | + } |
330 | +} |
331 | + |
332 | +TEST_F(ServerDisconnect, doesnt_stop_client_calling_API_functions) |
333 | +{ |
334 | + mt::CrossProcessAction connect; |
335 | + mt::CrossProcessAction create_surface; |
336 | + mt::CrossProcessAction configure_display; |
337 | + mt::CrossProcessAction disconnect; |
338 | + |
339 | + auto const client = new_client_process([&] |
340 | + { |
341 | + MirConnection* connection{nullptr}; |
342 | + |
343 | + connect.exec([&] { |
344 | + connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
345 | + EXPECT_TRUE(mir_connection_is_valid(connection)); |
346 | + /* |
347 | + * Set a null callback to avoid killing the process |
348 | + * (default callback raises SIGHUP). |
349 | + */ |
350 | + mir_connection_set_lifecycle_event_callback(connection, |
351 | + null_lifecycle_callback, |
352 | + nullptr); |
353 | + }); |
354 | + |
355 | + MirSurface* surf; |
356 | + |
357 | + create_surface.exec([&] { |
358 | + MirSurfaceParameters const parameters = |
359 | + { |
360 | + __PRETTY_FUNCTION__, |
361 | + 1, 1, |
362 | + mir_pixel_format_abgr_8888, |
363 | + mir_buffer_usage_hardware, |
364 | + mir_display_output_id_invalid |
365 | + }; |
366 | + surf = mir_connection_create_surface_sync(connection, ¶meters); |
367 | + }); |
368 | + |
369 | + configure_display.exec([&] { |
370 | + auto config = mir_connection_create_display_config(connection); |
371 | + mir_wait_for(mir_connection_apply_display_config(connection, config)); |
372 | + mir_display_config_destroy(config); |
373 | + }); |
374 | + |
375 | + disconnect.exec([&] { |
376 | + mir_surface_release_sync(surf); |
377 | + mir_connection_release(connection); |
378 | + }); |
379 | + }); |
380 | + |
381 | + if (is_test_process()) |
382 | + { |
383 | + connect(); |
384 | + stop_server(); |
385 | + /* While trying to create a surface the connection break will be detected */ |
386 | + create_surface(); |
387 | + |
388 | + /* Trying to configure the display shouldn't block */ |
389 | + configure_display(); |
390 | + /* Trying to disconnect at this point shouldn't block */ |
391 | + disconnect(); |
392 | + } |
393 | +} |
394 | + |
395 | +TEST_F(ServerDisconnect, causes_client_to_terminate_by_default) |
396 | +{ |
397 | + mt::CrossProcessAction connect; |
398 | + mtf::CrossProcessSync create_surface_sync; |
399 | + |
400 | + auto const client = new_client_process([&] |
401 | + { |
402 | + MirConnection* connection{nullptr}; |
403 | + |
404 | + connect.exec([&] { |
405 | + connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
406 | + EXPECT_TRUE(mir_connection_is_valid(connection)); |
407 | + }); |
408 | + |
409 | + create_surface_sync.wait_for_signal_ready_for(); |
410 | + |
411 | MirSurfaceParameters const parameters = |
412 | { |
413 | __PRETTY_FUNCTION__, |
414 | @@ -107,129 +186,26 @@ |
415 | mir_buffer_usage_hardware, |
416 | mir_display_output_id_invalid |
417 | }; |
418 | - surf = mir_connection_create_surface_sync(connection, ¶meters); |
419 | - }); |
420 | - |
421 | - configure_display.exec([&] { |
422 | - auto config = mir_connection_create_display_config(connection); |
423 | - mir_wait_for(mir_connection_apply_display_config(connection, config)); |
424 | - mir_display_config_destroy(config); |
425 | - }); |
426 | - |
427 | - disconnect.exec([&] { |
428 | - mir_surface_release_sync(surf); |
429 | + mir_connection_create_surface_sync(connection, ¶meters); |
430 | + |
431 | mir_connection_release(connection); |
432 | }); |
433 | - } |
434 | - |
435 | - static void null_lifecycle_callback(MirConnection*, MirLifecycleState, void*) |
436 | - { |
437 | - } |
438 | - |
439 | - mt::CrossProcessAction connect; |
440 | - mt::CrossProcessAction create_surface; |
441 | - mt::CrossProcessAction configure_display; |
442 | - mt::CrossProcessAction disconnect; |
443 | -private: |
444 | - MirSurface* surf; |
445 | -}; |
446 | - |
447 | -/* |
448 | - * This client will self-terminate on server connection break (through the default |
449 | - * lifecycle handler). |
450 | - */ |
451 | -struct TerminatingTestingClientConfiguration : mtf::TestingClientConfiguration |
452 | -{ |
453 | - void exec() override |
454 | - { |
455 | - MirConnection* connection{nullptr}; |
456 | - |
457 | - connect.exec([&] { |
458 | - connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__); |
459 | - EXPECT_TRUE(mir_connection_is_valid(connection)); |
460 | - }); |
461 | - |
462 | - create_surface_sync.wait_for_signal_ready_for(); |
463 | - |
464 | - MirSurfaceParameters const parameters = |
465 | - { |
466 | - __PRETTY_FUNCTION__, |
467 | - 1, 1, |
468 | - mir_pixel_format_abgr_8888, |
469 | - mir_buffer_usage_hardware, |
470 | - mir_display_output_id_invalid |
471 | - }; |
472 | - mir_connection_create_surface_sync(connection, ¶meters); |
473 | - |
474 | - mir_connection_release(connection); |
475 | - } |
476 | - |
477 | - mt::CrossProcessAction connect; |
478 | - mtf::CrossProcessSync create_surface_sync; |
479 | -}; |
480 | -} |
481 | - |
482 | -TEST_F(ServerDisconnect, client_detects_server_shutdown) |
483 | -{ |
484 | - TestingServerConfiguration server_config; |
485 | - launch_server_process(server_config); |
486 | - |
487 | - MyTestingClientConfiguration client_config; |
488 | - launch_client_process(client_config); |
489 | - |
490 | - run_in_test_process([this, &client_config] |
491 | - { |
492 | - client_config.sync.wait_for_signal_ready_for(); |
493 | - shutdown_server_process(); |
494 | - }); |
495 | -} |
496 | - |
497 | -TEST_F(ServerDisconnect, client_can_call_connection_functions_after_connection_break_is_detected) |
498 | -{ |
499 | - TestingServerConfiguration server_config; |
500 | - launch_server_process(server_config); |
501 | - |
502 | - DisconnectingTestingClientConfiguration client_config; |
503 | - launch_client_process(client_config); |
504 | - |
505 | - run_in_test_process([this, &client_config] |
506 | - { |
507 | - client_config.connect(); |
508 | - shutdown_server_process(); |
509 | - /* While trying to create a surface the connection break will be detected */ |
510 | - client_config.create_surface(); |
511 | - |
512 | - /* Trying to configure the display shouldn't block */ |
513 | - client_config.configure_display(); |
514 | - /* Trying to disconnect at this point shouldn't block */ |
515 | - client_config.disconnect(); |
516 | - }); |
517 | -} |
518 | - |
519 | -TEST_F(ServerDisconnect, causes_client_to_terminate_by_default) |
520 | -{ |
521 | - TestingServerConfiguration server_config; |
522 | - launch_server_process(server_config); |
523 | - |
524 | - TerminatingTestingClientConfiguration client_config; |
525 | - launch_client_process(client_config); |
526 | - |
527 | - run_in_test_process([this, &client_config] |
528 | - { |
529 | - client_config.connect(); |
530 | - shutdown_server_process(); |
531 | + |
532 | + if (is_test_process()) |
533 | + { |
534 | + connect(); |
535 | + stop_server(); |
536 | |
537 | /* |
538 | * While trying to create a surface the connection break will be detected |
539 | * and the client should self-terminate. |
540 | */ |
541 | - client_config.create_surface_sync.signal_ready(); |
542 | + create_surface_sync.signal_ready(); |
543 | |
544 | - auto const client_results = wait_for_shutdown_client_processes(); |
545 | - ASSERT_EQ(1, client_results.size()); |
546 | + auto const client_result = client->wait_for_termination(); |
547 | EXPECT_EQ(mtf::TerminationReason::child_terminated_by_signal, |
548 | - client_results[0].reason); |
549 | - int sig = client_results[0].signal; |
550 | + client_result.reason); |
551 | + int sig = client_result.signal; |
552 | EXPECT_TRUE(sig == SIGHUP || sig == SIGKILL /* (Valgrind) */); |
553 | - }); |
554 | + } |
555 | } |
556 | |
557 | === added file 'tests/include/mir_test_framework/connected_client_with_a_surface.h' |
558 | --- tests/include/mir_test_framework/connected_client_with_a_surface.h 1970-01-01 00:00:00 +0000 |
559 | +++ tests/include/mir_test_framework/connected_client_with_a_surface.h 2014-11-18 16:56:14 +0000 |
560 | @@ -0,0 +1,36 @@ |
561 | +/* |
562 | + * Copyright © 2014 Canonical Ltd. |
563 | + * |
564 | + * This program is free software: you can redistribute it and/or modify it |
565 | + * under the terms of the GNU General Public License version 3, |
566 | + * as published by the Free Software Foundation. |
567 | + * |
568 | + * This program is distributed in the hope that it will be useful, |
569 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
570 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
571 | + * GNU General Public License for more details. |
572 | + * |
573 | + * You should have received a copy of the GNU General Public License |
574 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
575 | + * |
576 | + * Authored By: Alan Griffiths <alan@octopull.co.uk> |
577 | + */ |
578 | + |
579 | +#ifndef MIR_TEST_FRAMEWORK_CONNECTED_CLIENT_WITH_A_SURFACE_H_ |
580 | +#define MIR_TEST_FRAMEWORK_CONNECTED_CLIENT_WITH_A_SURFACE_H_ |
581 | + |
582 | +#include "mir_test_framework/connected_client_headless_server.h" |
583 | + |
584 | +namespace mir_test_framework |
585 | +{ |
586 | +struct ConnectedClientWithASurface : ConnectedClientHeadlessServer |
587 | +{ |
588 | + MirSurface* surface{nullptr}; |
589 | + |
590 | + void SetUp() override; |
591 | + |
592 | + void TearDown() override; |
593 | +}; |
594 | +} |
595 | + |
596 | +#endif /* MIR_TEST_FRAMEWORK_CONNECTED_CLIENT_WITH_A_SURFACE_H_ */ |
597 | |
598 | === modified file 'tests/include/mir_test_framework/interprocess_client_server_test.h' |
599 | --- tests/include/mir_test_framework/interprocess_client_server_test.h 2014-11-18 03:21:20 +0000 |
600 | +++ tests/include/mir_test_framework/interprocess_client_server_test.h 2014-11-18 16:56:14 +0000 |
601 | @@ -25,6 +25,7 @@ |
602 | namespace mir_test_framework |
603 | { |
604 | class Process; |
605 | +class Result; |
606 | |
607 | class InterprocessClientServerTest : public HeadlessTest |
608 | { |
609 | @@ -39,6 +40,8 @@ |
610 | |
611 | void run_in_client(std::function<void()> const& client_code); |
612 | |
613 | + auto new_client_process(std::function<void()> const& client_code) -> std::shared_ptr<Process>; |
614 | + |
615 | bool is_test_process() const; |
616 | |
617 | pid_t client_pid() const { return client_process_id; } |
618 | @@ -50,8 +53,12 @@ |
619 | |
620 | void expect_server_signalled(int signal); |
621 | |
622 | + void stop_server(); |
623 | + |
624 | bool sigkill_server_process(); |
625 | |
626 | + Result wait_for_shutdown_server_process(); |
627 | + |
628 | private: |
629 | |
630 | pid_t test_process_id{getpid()}; |
631 | |
632 | === modified file 'tests/mir_test_framework/CMakeLists.txt' |
633 | --- tests/mir_test_framework/CMakeLists.txt 2014-11-18 03:21:20 +0000 |
634 | +++ tests/mir_test_framework/CMakeLists.txt 2014-11-18 16:56:14 +0000 |
635 | @@ -15,6 +15,7 @@ |
636 | executable_path.cpp |
637 | command_line_server_configuration.cpp |
638 | connected_client_headless_server.cpp |
639 | + connected_client_with_a_surface.cpp |
640 | cross_process_sync.cpp |
641 | headless_in_process_server.cpp |
642 | headless_test.cpp |
643 | |
644 | === added file 'tests/mir_test_framework/connected_client_with_a_surface.cpp' |
645 | --- tests/mir_test_framework/connected_client_with_a_surface.cpp 1970-01-01 00:00:00 +0000 |
646 | +++ tests/mir_test_framework/connected_client_with_a_surface.cpp 2014-11-18 16:56:14 +0000 |
647 | @@ -0,0 +1,44 @@ |
648 | +/* |
649 | + * Copyright © 2014 Canonical Ltd. |
650 | + * |
651 | + * This program is free software: you can redistribute it and/or modify it |
652 | + * under the terms of the GNU General Public License version 3, |
653 | + * as published by the Free Software Foundation. |
654 | + * |
655 | + * This program is distributed in the hope that it will be useful, |
656 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
657 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
658 | + * GNU General Public License for more details. |
659 | + * |
660 | + * You should have received a copy of the GNU General Public License |
661 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
662 | + * |
663 | + * Authored By: Alan Griffiths <alan@octopull.co.uk> |
664 | + */ |
665 | + |
666 | +#include "mir_test_framework/connected_client_with_a_surface.h" |
667 | + |
668 | +namespace mtf = mir_test_framework; |
669 | + |
670 | +void mtf::ConnectedClientWithASurface::SetUp() |
671 | +{ |
672 | + ConnectedClientHeadlessServer::SetUp(); |
673 | + |
674 | + MirSurfaceParameters request_params = |
675 | + { |
676 | + __PRETTY_FUNCTION__, |
677 | + 640, 480, |
678 | + mir_pixel_format_abgr_8888, |
679 | + mir_buffer_usage_hardware, |
680 | + mir_display_output_id_invalid |
681 | + }; |
682 | + |
683 | + surface = mir_connection_create_surface_sync(connection, &request_params); |
684 | + ASSERT_TRUE(mir_surface_is_valid(surface)); |
685 | +} |
686 | + |
687 | +void mtf::ConnectedClientWithASurface::TearDown() |
688 | +{ |
689 | + mir_surface_release_sync(surface); |
690 | + ConnectedClientHeadlessServer::TearDown(); |
691 | +} |
692 | |
693 | === modified file 'tests/mir_test_framework/interprocess_client_server_test.cpp' |
694 | --- tests/mir_test_framework/interprocess_client_server_test.cpp 2014-11-18 03:21:20 +0000 |
695 | +++ tests/mir_test_framework/interprocess_client_server_test.cpp 2014-11-18 16:56:14 +0000 |
696 | @@ -82,8 +82,20 @@ |
697 | |
698 | void mtf::InterprocessClientServerTest::run_in_client(std::function<void()> const& client_code) |
699 | { |
700 | + auto const client_process = new_client_process(client_code); |
701 | + |
702 | if (test_process_id != getpid()) return; |
703 | |
704 | + Result result = client_process->wait_for_termination(); |
705 | + EXPECT_THAT(result.exit_code, Eq(EXIT_SUCCESS)); |
706 | +} |
707 | + |
708 | +auto mtf::InterprocessClientServerTest::new_client_process(std::function<void()> const& client_code) |
709 | +-> std::shared_ptr<Process> |
710 | +{ |
711 | + if (test_process_id != getpid()) |
712 | + return std::shared_ptr<Process>{}; |
713 | + |
714 | pid_t pid = fork(); |
715 | |
716 | if (pid < 0) |
717 | @@ -96,13 +108,12 @@ |
718 | process_tag = "client"; |
719 | add_to_environment("MIR_SOCKET", mir_test_socket); |
720 | client_code(); |
721 | + return std::shared_ptr<Process>{}; |
722 | } |
723 | else |
724 | { |
725 | client_process_id = pid; |
726 | - auto const client_process = std::make_shared<Process>(pid); |
727 | - Result result = client_process->wait_for_termination(); |
728 | - EXPECT_THAT(result.exit_code, Eq(EXIT_SUCCESS)); |
729 | + return std::make_shared<Process>(pid); |
730 | } |
731 | } |
732 | |
733 | @@ -116,7 +127,16 @@ |
734 | if (server_process_id == getpid()) |
735 | { |
736 | shutdown_sync.wait_for_signal_ready_for(); |
737 | - stop_server(); |
738 | + } |
739 | + |
740 | + stop_server(); |
741 | +} |
742 | + |
743 | +void mtf::InterprocessClientServerTest::stop_server() |
744 | +{ |
745 | + if (server_process_id == getpid()) |
746 | + { |
747 | + HeadlessTest::stop_server(); |
748 | } |
749 | |
750 | if (test_process_id != getpid()) return; |
751 | @@ -156,9 +176,19 @@ |
752 | throw std::logic_error("No server process to kill"); |
753 | |
754 | server_process->kill(); |
755 | - auto result = server_process->wait_for_termination(); |
756 | - server_process.reset(); |
757 | + auto result = wait_for_shutdown_server_process(); |
758 | |
759 | return result.reason == TerminationReason::child_terminated_by_signal && |
760 | result.signal == SIGKILL; |
761 | } |
762 | + |
763 | +mtf::Result mtf::InterprocessClientServerTest::wait_for_shutdown_server_process() |
764 | +{ |
765 | + |
766 | + if (!server_process) |
767 | + throw std::logic_error("No server process to monitor"); |
768 | + |
769 | + Result result = server_process->wait_for_termination(); |
770 | + server_process.reset(); |
771 | + return result; |
772 | +} |
PASSED: Continuous integration, rev:2078 jenkins. qa.ubuntu. com/job/ mir-ci/ 2153/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/187 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/187 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/167 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 142 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 142/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 167 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 167/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/3438 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 15965
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/2153/ rebuild
http://