Merge lp:~afrantzis/mir/platform-operation-set-gbm-device into lp:mir
- platform-operation-set-gbm-device
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alexandros Frantzis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2286 |
Proposed branch: | lp:~afrantzis/mir/platform-operation-set-gbm-device |
Merge into: | lp:mir |
Prerequisite: | lp:~afrantzis/mir/client-platform-populate-package |
Diff against target: |
763 lines (+306/-143) 17 files modified
src/client/mir_connection.cpp (+8/-20) src/client/mir_connection.h (+0/-4) src/client/mir_connection_api.cpp (+36/-11) src/include/client/mir/client_platform.h (+11/-0) src/platforms/android/client/android_client_platform.cpp (+6/-0) src/platforms/android/client/android_client_platform.h (+1/-1) src/platforms/mesa/client/client_platform.cpp (+46/-1) src/platforms/mesa/client/client_platform.h (+4/-0) src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h (+19/-2) tests/acceptance-tests/CMakeLists.txt (+0/-1) tests/acceptance-tests/test_client_library_drm.cpp (+0/-46) tests/acceptance-tests/test_client_library_errors.cpp (+5/-0) tests/include/mir_test_framework/client_platform_factory.h (+3/-9) tests/mir_test_framework/stub_client_platform_factory.cpp (+5/-0) tests/unit-tests/client/mesa/test_client_platform.cpp (+77/-6) tests/unit-tests/client/test_client_mir_surface.cpp (+6/-0) tests/unit-tests/client/test_mir_connection.cpp (+79/-42) |
To merge this branch: | bzr merge lp:~afrantzis/mir/platform-operation-set-gbm-device |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Robert Carr (community) | Approve | ||
Alan Griffiths | Approve | ||
Review via email: mp+248125@code.launchpad.net |
This proposal supersedes a proposal from 2015-01-30.
Commit message
client: Add set_gbm_device platform operation
Description of the change
client: Add set_gbm_device platform operation
Implement the set_gbm_device functionality as a platform operation. The mir_connection_
This changes also allows us to remove the final platform specific piece from the nested server, which will happen in an upcoming MP.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2281
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://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'src/client/mir_connection.cpp' |
2 | --- src/client/mir_connection.cpp 2015-01-30 14:38:25 +0000 |
3 | +++ src/client/mir_connection.cpp 2015-01-30 14:38:25 +0000 |
4 | @@ -361,6 +361,14 @@ |
5 | MirPlatformMessage const* request, |
6 | mir_platform_operation_callback callback, void* context) |
7 | { |
8 | + auto const client_response = platform->platform_operation(request); |
9 | + if (client_response) |
10 | + { |
11 | + set_error_message(""); |
12 | + callback(this, client_response, context); |
13 | + return nullptr; |
14 | + } |
15 | + |
16 | mir::protobuf::PlatformOperationMessage protobuf_request; |
17 | |
18 | protobuf_request.set_opcode(opcode); |
19 | @@ -420,11 +428,6 @@ |
20 | platform_package.fd_items = platform.fd_size(); |
21 | for (int i = 0; i != platform.fd_size(); ++i) |
22 | platform_package.fd[i] = platform.fd(i); |
23 | - |
24 | - // TODO: Replace the extra platform data mechanism with a |
25 | - // client side, platform specific operation |
26 | - for (auto d : extra_platform_data) |
27 | - platform_package.data[platform_package.data_items++] = d; |
28 | } |
29 | else |
30 | { |
31 | @@ -567,21 +570,6 @@ |
32 | return &configure_display_wait_handle; |
33 | } |
34 | |
35 | -bool MirConnection::set_extra_platform_data( |
36 | - std::vector<int> const& extra_platform_data_arg) |
37 | -{ |
38 | - std::lock_guard<decltype(mutex)> lock(mutex); |
39 | - |
40 | - auto const total_data_size = |
41 | - connect_result.platform().data_size() + extra_platform_data_arg.size(); |
42 | - |
43 | - if (total_data_size > mir_platform_package_max) |
44 | - return false; |
45 | - |
46 | - extra_platform_data = extra_platform_data_arg; |
47 | - return true; |
48 | -} |
49 | - |
50 | mir::protobuf::DisplayServer& MirConnection::display_server() |
51 | { |
52 | return server; |
53 | |
54 | === modified file 'src/client/mir_connection.h' |
55 | --- src/client/mir_connection.h 2015-01-30 14:38:25 +0000 |
56 | +++ src/client/mir_connection.h 2015-01-30 14:38:25 +0000 |
57 | @@ -137,8 +137,6 @@ |
58 | MirWaitHandle* configure_display(MirDisplayConfiguration* configuration); |
59 | void done_display_configure(); |
60 | |
61 | - bool set_extra_platform_data(std::vector<int> const& extra_platform_data); |
62 | - |
63 | std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const |
64 | { |
65 | return channel; |
66 | @@ -197,8 +195,6 @@ |
67 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; |
68 | |
69 | std::unique_ptr<mir::dispatch::SimpleDispatchThread> const eventloop; |
70 | - |
71 | - std::vector<int> extra_platform_data; |
72 | |
73 | std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory; |
74 | |
75 | |
76 | === modified file 'src/client/mir_connection_api.cpp' |
77 | --- src/client/mir_connection_api.cpp 2015-01-26 15:53:18 +0000 |
78 | +++ src/client/mir_connection_api.cpp 2015-01-30 14:38:25 +0000 |
79 | @@ -51,11 +51,6 @@ |
80 | *context = result; |
81 | } |
82 | |
83 | -size_t division_ceiling(size_t a, size_t b) |
84 | -{ |
85 | - return ((a - 1) / b) + 1; |
86 | -} |
87 | - |
88 | class DefaultMirConnectionAPI : public mcl::MirConnectionAPI |
89 | { |
90 | public: |
91 | @@ -356,6 +351,21 @@ |
92 | auth_magic_context->callback(auth_response->status, auth_magic_context->context); |
93 | } |
94 | |
95 | +void assign_set_gbm_device_status( |
96 | + MirConnection*, MirPlatformMessage* response, void* context) |
97 | +{ |
98 | + auto const response_msg = mir::raii::deleter_for( |
99 | + response, |
100 | + &mir_platform_message_release); |
101 | + |
102 | + auto const response_data = mir_platform_message_get_data(response_msg.get()); |
103 | + auto const set_gbm_device_response_ptr = |
104 | + reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); |
105 | + |
106 | + auto status_ptr = static_cast<int*>(context); |
107 | + *status_ptr = set_gbm_device_response_ptr->status; |
108 | +} |
109 | + |
110 | } |
111 | |
112 | MirWaitHandle* mir_connection_drm_auth_magic(MirConnection* connection, |
113 | @@ -386,10 +396,25 @@ |
114 | int mir_connection_drm_set_gbm_device(MirConnection* connection, |
115 | struct gbm_device* gbm_dev) |
116 | { |
117 | - size_t const pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); |
118 | - std::vector<int> extra_data(pointer_size_in_ints); |
119 | - |
120 | - memcpy(extra_data.data(), &gbm_dev, sizeof(gbm_dev)); |
121 | - |
122 | - return connection->set_extra_platform_data(extra_data); |
123 | + MirMesaSetGBMDeviceRequest const request{gbm_dev}; |
124 | + |
125 | + auto const msg = mir::raii::deleter_for( |
126 | + mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), |
127 | + &mir_platform_message_release); |
128 | + |
129 | + mir_platform_message_set_data(msg.get(), &request, sizeof(request)); |
130 | + |
131 | + static int const success{0}; |
132 | + int status{-1}; |
133 | + |
134 | + auto wh = mir_connection_platform_operation( |
135 | + connection, |
136 | + MirMesaPlatformOperation::set_gbm_device, |
137 | + msg.get(), |
138 | + assign_set_gbm_device_status, |
139 | + &status); |
140 | + |
141 | + mir_wait_for(wh); |
142 | + |
143 | + return status == success; |
144 | } |
145 | |
146 | === modified file 'src/include/client/mir/client_platform.h' |
147 | --- src/include/client/mir/client_platform.h 2015-01-30 14:38:25 +0000 |
148 | +++ src/include/client/mir/client_platform.h 2015-01-30 14:38:25 +0000 |
149 | @@ -49,6 +49,17 @@ |
150 | |
151 | virtual MirPlatformType platform_type() const = 0; |
152 | virtual void populate(MirPlatformPackage& package) const = 0; |
153 | + /** |
154 | + * Perform a platform operation. |
155 | + * |
156 | + * The returned platform message is owned by the caller and should be |
157 | + * released with mir_platform_message_release(). |
158 | + * |
159 | + * \param [in] request The platform operation request |
160 | + * \return The platform operation reply, or a nullptr if the |
161 | + * requested operation is not supported |
162 | + */ |
163 | + virtual MirPlatformMessage* platform_operation(MirPlatformMessage const* request) = 0; |
164 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; |
165 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) = 0; |
166 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; |
167 | |
168 | === modified file 'src/platforms/android/client/android_client_platform.cpp' |
169 | --- src/platforms/android/client/android_client_platform.cpp 2015-01-30 14:38:25 +0000 |
170 | +++ src/platforms/android/client/android_client_platform.cpp 2015-01-30 14:38:25 +0000 |
171 | @@ -112,6 +112,12 @@ |
172 | context->populate_server_package(package); |
173 | } |
174 | |
175 | +MirPlatformMessage* mcla::AndroidClientPlatform::platform_operation( |
176 | + MirPlatformMessage const*) |
177 | +{ |
178 | + return nullptr; |
179 | +} |
180 | + |
181 | MirNativeBuffer* mcla::AndroidClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
182 | { |
183 | return buf->anwb(); |
184 | |
185 | === modified file 'src/platforms/android/client/android_client_platform.h' |
186 | --- src/platforms/android/client/android_client_platform.h 2015-01-30 14:38:25 +0000 |
187 | +++ src/platforms/android/client/android_client_platform.h 2015-01-30 14:38:25 +0000 |
188 | @@ -35,6 +35,7 @@ |
189 | AndroidClientPlatform(ClientContext* const context); |
190 | MirPlatformType platform_type() const override; |
191 | void populate(MirPlatformPackage& package) const override; |
192 | + MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; |
193 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
194 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
195 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
196 | @@ -42,7 +43,6 @@ |
197 | |
198 | private: |
199 | ClientContext* const context; |
200 | - |
201 | }; |
202 | |
203 | } |
204 | |
205 | === modified file 'src/platforms/mesa/client/client_platform.cpp' |
206 | --- src/platforms/mesa/client/client_platform.cpp 2015-01-30 14:38:25 +0000 |
207 | +++ src/platforms/mesa/client/client_platform.cpp 2015-01-30 14:38:25 +0000 |
208 | @@ -23,6 +23,9 @@ |
209 | #include "native_surface.h" |
210 | #include "mir/client_buffer_factory.h" |
211 | #include "mir/client_context.h" |
212 | +#include "mir_toolkit/mesa/platform_operation.h" |
213 | + |
214 | +#include <cstring> |
215 | |
216 | namespace mcl=mir::client; |
217 | namespace mclm=mir::client::mesa; |
218 | @@ -47,6 +50,11 @@ |
219 | mcl::EGLNativeDisplayContainer& container; |
220 | }; |
221 | |
222 | +constexpr size_t division_ceiling(size_t a, size_t b) |
223 | +{ |
224 | + return ((a - 1) / b) + 1; |
225 | +} |
226 | + |
227 | } |
228 | |
229 | mclm::ClientPlatform::ClientPlatform( |
230 | @@ -55,7 +63,8 @@ |
231 | mcl::EGLNativeDisplayContainer& display_container) |
232 | : context{context}, |
233 | buffer_file_ops{buffer_file_ops}, |
234 | - display_container(display_container) |
235 | + display_container(display_container), |
236 | + gbm_dev{nullptr} |
237 | { |
238 | } |
239 | |
240 | @@ -108,7 +117,43 @@ |
241 | |
242 | void mclm::ClientPlatform::populate(MirPlatformPackage& package) const |
243 | { |
244 | + size_t constexpr pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); |
245 | + |
246 | context->populate_server_package(package); |
247 | + |
248 | + auto const total_data_size = package.data_items + pointer_size_in_ints; |
249 | + if (gbm_dev && total_data_size <= mir_platform_package_max) |
250 | + { |
251 | + int gbm_ptr[pointer_size_in_ints]{}; |
252 | + std::memcpy(&gbm_ptr, &gbm_dev, sizeof(gbm_dev)); |
253 | + |
254 | + for (auto i : gbm_ptr) |
255 | + package.data[package.data_items++] = i; |
256 | + } |
257 | +} |
258 | + |
259 | +MirPlatformMessage* mclm::ClientPlatform::platform_operation( |
260 | + MirPlatformMessage const* msg) |
261 | +{ |
262 | + auto const op = mir_platform_message_get_opcode(msg); |
263 | + |
264 | + if (op == MirMesaPlatformOperation::set_gbm_device) |
265 | + { |
266 | + auto const msg_data = mir_platform_message_get_data(msg); |
267 | + auto const set_gbm_device_request_ptr = |
268 | + reinterpret_cast<MirMesaSetGBMDeviceRequest const*>(msg_data.data); |
269 | + |
270 | + gbm_dev = set_gbm_device_request_ptr->device; |
271 | + |
272 | + static int const success{0}; |
273 | + MirMesaSetGBMDeviceResponse const response{success}; |
274 | + auto const response_msg = mir_platform_message_create(op); |
275 | + mir_platform_message_set_data(response_msg, &response, sizeof(response)); |
276 | + |
277 | + return response_msg; |
278 | + } |
279 | + |
280 | + return nullptr; |
281 | } |
282 | |
283 | MirNativeBuffer* mclm::ClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
284 | |
285 | === modified file 'src/platforms/mesa/client/client_platform.h' |
286 | --- src/platforms/mesa/client/client_platform.h 2015-01-30 14:38:25 +0000 |
287 | +++ src/platforms/mesa/client/client_platform.h 2015-01-30 14:38:25 +0000 |
288 | @@ -20,6 +20,8 @@ |
289 | |
290 | #include "mir/client_platform.h" |
291 | |
292 | +struct gbm_device; |
293 | + |
294 | namespace mir |
295 | { |
296 | namespace client |
297 | @@ -41,6 +43,7 @@ |
298 | |
299 | MirPlatformType platform_type() const override; |
300 | void populate(MirPlatformPackage& package) const override; |
301 | + MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; |
302 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
303 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
304 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
305 | @@ -50,6 +53,7 @@ |
306 | ClientContext* const context; |
307 | std::shared_ptr<BufferFileOps> const buffer_file_ops; |
308 | EGLNativeDisplayContainer& display_container; |
309 | + gbm_device* gbm_dev; |
310 | }; |
311 | |
312 | } |
313 | |
314 | === modified file 'src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h' |
315 | --- src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-01-27 14:59:08 +0000 |
316 | +++ src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-01-30 14:38:25 +0000 |
317 | @@ -35,7 +35,8 @@ |
318 | enum MirMesaPlatformOperation |
319 | { |
320 | auth_magic = 1, |
321 | - auth_fd = 2 |
322 | + auth_fd = 2, |
323 | + set_gbm_device = 3 |
324 | }; |
325 | |
326 | /* |
327 | @@ -49,7 +50,23 @@ |
328 | |
329 | struct MirMesaAuthMagicResponse |
330 | { |
331 | - int status; |
332 | + int status; /* 0 on success, a positive error number on failure */ |
333 | +}; |
334 | + |
335 | +/* |
336 | + * MesaPlatformOperation::set_gbm_device related structures |
337 | + */ |
338 | + |
339 | +struct gbm_device; |
340 | + |
341 | +struct MirMesaSetGBMDeviceRequest |
342 | +{ |
343 | + struct gbm_device* device; |
344 | +}; |
345 | + |
346 | +struct MirMesaSetGBMDeviceResponse |
347 | +{ |
348 | + int status; /* 0 on success, a positive error number on failure */ |
349 | }; |
350 | |
351 | #ifdef __cplusplus |
352 | |
353 | === modified file 'tests/acceptance-tests/CMakeLists.txt' |
354 | --- tests/acceptance-tests/CMakeLists.txt 2015-01-19 06:55:41 +0000 |
355 | +++ tests/acceptance-tests/CMakeLists.txt 2015-01-30 14:38:25 +0000 |
356 | @@ -25,7 +25,6 @@ |
357 | test_display_configuration.cpp |
358 | test_surfaces_with_output_id.cpp |
359 | test_server_disconnect.cpp |
360 | - test_client_library_drm.cpp |
361 | test_prompt_session_client_api.cpp |
362 | test_client_screencast.cpp |
363 | test_client_surface_visibility.cpp |
364 | |
365 | === removed file 'tests/acceptance-tests/test_client_library_drm.cpp' |
366 | --- tests/acceptance-tests/test_client_library_drm.cpp 2015-01-14 06:39:13 +0000 |
367 | +++ tests/acceptance-tests/test_client_library_drm.cpp 1970-01-01 00:00:00 +0000 |
368 | @@ -1,46 +0,0 @@ |
369 | -/* |
370 | - * Copyright © 2013-2014 Canonical Ltd. |
371 | - * |
372 | - * This program is free software: you can redistribute it and/or modify |
373 | - * it under the terms of the GNU General Public License version 3 as |
374 | - * published by the Free Software Foundation. |
375 | - * |
376 | - * This program is distributed in the hope that it will be useful, |
377 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
378 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
379 | - * GNU General Public License for more details. |
380 | - * |
381 | - * You should have received a copy of the GNU General Public License |
382 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
383 | - * |
384 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
385 | - */ |
386 | - |
387 | -#include "mir_toolkit/mir_client_library_drm.h" |
388 | - |
389 | -#include "mir_test_framework/connected_client_headless_server.h" |
390 | - |
391 | -#include <gtest/gtest.h> |
392 | -#include <gmock/gmock.h> |
393 | - |
394 | -namespace mtf = mir_test_framework; |
395 | -using namespace testing; |
396 | - |
397 | -using MirClientLibraryDrmTest = mtf::ConnectedClientHeadlessServer; |
398 | - |
399 | -TEST_F(MirClientLibraryDrmTest, sets_gbm_device_in_platform_data) |
400 | -{ |
401 | - struct gbm_device* dev = reinterpret_cast<struct gbm_device*>(connection); |
402 | - |
403 | - MirPlatformPackage pkg; |
404 | - |
405 | - mir_connection_get_platform(connection, &pkg); |
406 | - int const previous_data_count{pkg.data_items}; |
407 | - |
408 | - mir_connection_drm_set_gbm_device(connection, dev); |
409 | - mir_connection_get_platform(connection, &pkg); |
410 | - |
411 | - EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(dev) / sizeof(int)))); |
412 | - EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), |
413 | - Eq(dev)); |
414 | -} |
415 | |
416 | === modified file 'tests/acceptance-tests/test_client_library_errors.cpp' |
417 | --- tests/acceptance-tests/test_client_library_errors.cpp 2015-01-30 14:38:25 +0000 |
418 | +++ tests/acceptance-tests/test_client_library_errors.cpp 2015-01-30 14:38:25 +0000 |
419 | @@ -77,6 +77,11 @@ |
420 | { |
421 | } |
422 | |
423 | + MirPlatformMessage* platform_operation(MirPlatformMessage const*) override |
424 | + { |
425 | + return nullptr; |
426 | + } |
427 | + |
428 | MirPlatformType platform_type() const |
429 | { |
430 | BOOST_THROW_EXCEPTION(std::runtime_error{exception_text}); |
431 | |
432 | === modified file 'tests/include/mir_test_framework/client_platform_factory.h' |
433 | --- tests/include/mir_test_framework/client_platform_factory.h 2015-01-30 14:38:25 +0000 |
434 | +++ tests/include/mir_test_framework/client_platform_factory.h 2015-01-30 14:38:25 +0000 |
435 | @@ -42,19 +42,13 @@ |
436 | return platform_factory(&ctx); |
437 | } |
438 | |
439 | -std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform() |
440 | +std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform( |
441 | + mir::client::ClientContext* client_context) |
442 | { |
443 | using namespace testing; |
444 | - mtd::MockClientContext ctx; |
445 | - ON_CALL(ctx, populate_server_package(_)) |
446 | - .WillByDefault(Invoke([](MirPlatformPackage& package) |
447 | - { |
448 | - ::memset(&package, 0, sizeof(package)); |
449 | - package.fd_items = 1; |
450 | - })); |
451 | platform_library = std::make_shared<mir::SharedLibrary>(client_platform("mesa.so")); |
452 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); |
453 | - return platform_factory(&ctx); |
454 | + return platform_factory(client_context); |
455 | } |
456 | |
457 | std::shared_ptr<mir::SharedLibrary> |
458 | |
459 | === modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp' |
460 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 2015-01-30 14:38:25 +0000 |
461 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2015-01-30 14:38:25 +0000 |
462 | @@ -50,6 +50,11 @@ |
463 | context->populate_server_package(package); |
464 | } |
465 | |
466 | + MirPlatformMessage* platform_operation(MirPlatformMessage const*) override |
467 | + { |
468 | + return nullptr; |
469 | + } |
470 | + |
471 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
472 | { |
473 | return std::make_shared<mtd::StubClientBufferFactory>(); |
474 | |
475 | === modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp' |
476 | --- tests/unit-tests/client/mesa/test_client_platform.cpp 2015-01-22 21:42:26 +0000 |
477 | +++ tests/unit-tests/client/mesa/test_client_platform.cpp 2015-01-30 14:38:25 +0000 |
478 | @@ -18,23 +18,56 @@ |
479 | |
480 | #include "mir/client_platform.h" |
481 | #include "mir/shared_library.h" |
482 | +#include "mir/raii.h" |
483 | #include "src/platforms/mesa/client/mesa_native_display_container.h" |
484 | #include "mir_test_framework/client_platform_factory.h" |
485 | -#include "mir_test_doubles/mock_egl_native_surface.h" |
486 | |
487 | +#include "mir_toolkit/mir_client_library.h" |
488 | #include "mir_toolkit/mesa/native_display.h" |
489 | +#include "mir_toolkit/mesa/platform_operation.h" |
490 | |
491 | #include <gtest/gtest.h> |
492 | +#include <gmock/gmock.h> |
493 | |
494 | namespace mcl = mir::client; |
495 | namespace mclm = mir::client::mesa; |
496 | -namespace mt = mir::test; |
497 | -namespace mtd = mir::test::doubles; |
498 | namespace mtf = mir_test_framework; |
499 | |
500 | -TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released) |
501 | -{ |
502 | - auto platform = mtf::create_mesa_client_platform(); |
503 | +namespace |
504 | +{ |
505 | + |
506 | +struct StubClientContext : mcl::ClientContext |
507 | +{ |
508 | + void populate_server_package(MirPlatformPackage& platform_package) override |
509 | + { |
510 | + platform_package.data_items = 0; |
511 | + platform_package.fd_items = 1; |
512 | + } |
513 | + |
514 | +}; |
515 | + |
516 | +struct MesaClientPlatformTest : testing::Test |
517 | +{ |
518 | + MirPlatformMessage* set_gbm_device(gbm_device* dev) |
519 | + { |
520 | + auto request_msg = mir::raii::deleter_for( |
521 | + mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), |
522 | + &mir_platform_message_release); |
523 | + MirMesaSetGBMDeviceRequest const request{dev}; |
524 | + mir_platform_message_set_data(request_msg.get(), &request, sizeof(request)); |
525 | + |
526 | + return platform->platform_operation(request_msg.get()); |
527 | + } |
528 | + |
529 | + StubClientContext client_context; |
530 | + std::shared_ptr<mir::client::ClientPlatform> platform = |
531 | + mtf::create_mesa_client_platform(&client_context); |
532 | +}; |
533 | + |
534 | +} |
535 | + |
536 | +TEST_F(MesaClientPlatformTest, egl_native_display_is_valid_until_released) |
537 | +{ |
538 | auto platform_lib = mtf::get_platform_library(); |
539 | |
540 | MirMesaEGLNativeDisplay* nd; |
541 | @@ -47,3 +80,41 @@ |
542 | } |
543 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); |
544 | } |
545 | + |
546 | +TEST_F(MesaClientPlatformTest, handles_set_gbm_device_platform_operation) |
547 | +{ |
548 | + using namespace testing; |
549 | + |
550 | + int const success{0}; |
551 | + auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); |
552 | + |
553 | + auto response_msg = mir::raii::deleter_for( |
554 | + set_gbm_device(gbm_dev_dummy), |
555 | + &mir_platform_message_release); |
556 | + |
557 | + ASSERT_THAT(response_msg, NotNull()); |
558 | + auto const response_data = mir_platform_message_get_data(response_msg.get()); |
559 | + ASSERT_THAT(response_data.size, Eq(sizeof(MirMesaSetGBMDeviceResponse))); |
560 | + auto const response_ptr = |
561 | + reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); |
562 | + EXPECT_THAT(response_ptr->status, Eq(success)); |
563 | +} |
564 | + |
565 | +TEST_F(MesaClientPlatformTest, appends_gbm_device_to_platform_package) |
566 | +{ |
567 | + using namespace testing; |
568 | + |
569 | + MirPlatformPackage pkg; |
570 | + platform->populate(pkg); |
571 | + int const previous_data_count{pkg.data_items}; |
572 | + auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); |
573 | + |
574 | + auto response_msg = mir::raii::deleter_for( |
575 | + set_gbm_device(gbm_dev_dummy), |
576 | + &mir_platform_message_release); |
577 | + |
578 | + platform->populate(pkg); |
579 | + EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(gbm_dev_dummy) / sizeof(int)))); |
580 | + EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), |
581 | + Eq(gbm_dev_dummy)); |
582 | +} |
583 | |
584 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' |
585 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2015-01-30 14:38:25 +0000 |
586 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2015-01-30 14:38:25 +0000 |
587 | @@ -211,6 +211,12 @@ |
588 | { |
589 | } |
590 | |
591 | + MirPlatformMessage* platform_operation( |
592 | + MirPlatformMessage const*) override |
593 | + { |
594 | + return nullptr; |
595 | + } |
596 | + |
597 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
598 | { |
599 | return std::make_shared<mtd::StubClientBufferFactory>(); |
600 | |
601 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' |
602 | --- tests/unit-tests/client/test_mir_connection.cpp 2015-01-30 14:38:25 +0000 |
603 | +++ tests/unit-tests/client/test_mir_connection.cpp 2015-01-30 14:38:25 +0000 |
604 | @@ -28,6 +28,7 @@ |
605 | #include "src/client/mir_surface.h" |
606 | #include "mir/client_buffer_factory.h" |
607 | #include "mir/dispatch/dispatchable.h" |
608 | +#include "mir/raii.h" |
609 | |
610 | #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */ |
611 | #include "mir_test/test_protobuf_server.h" |
612 | @@ -74,12 +75,19 @@ |
613 | { |
614 | configure_display_sent(static_cast<mp::DisplayConfiguration const*>(parameters)); |
615 | } |
616 | + else if (method->name() == "platform_operation") |
617 | + { |
618 | + platform_operation(static_cast<mp::PlatformOperationMessage const*>(parameters), |
619 | + static_cast<mp::PlatformOperationMessage*>(response)); |
620 | + } |
621 | |
622 | complete->Run(); |
623 | } |
624 | |
625 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
626 | MOCK_METHOD1(configure_display_sent, void(mp::DisplayConfiguration const*)); |
627 | + MOCK_METHOD2(platform_operation, |
628 | + void(mp::PlatformOperationMessage const*, mp::PlatformOperationMessage*)); |
629 | |
630 | MOCK_CONST_METHOD0(watch_fd, mir::Fd()); |
631 | MOCK_METHOD1(dispatch, bool(md::FdEvents)); |
632 | @@ -101,6 +109,8 @@ |
633 | .WillByDefault(Return(std::make_shared<mtd::StubClientBufferFactory>())); |
634 | ON_CALL(*this, create_egl_native_window(_)) |
635 | .WillByDefault(Return(std::shared_ptr<EGLNativeWindowType>())); |
636 | + ON_CALL(*this, platform_operation(_)) |
637 | + .WillByDefault(Return(nullptr)); |
638 | } |
639 | |
640 | void set_client_context(mcl::ClientContext* ctx) |
641 | @@ -115,6 +125,7 @@ |
642 | |
643 | MOCK_CONST_METHOD1(convert_native_buffer, MirNativeBuffer*(mir::graphics::NativeBuffer*)); |
644 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); |
645 | + MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*)); |
646 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); |
647 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<EGLNativeWindowType>(mcl::EGLNativeSurface*)); |
648 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); |
649 | @@ -568,46 +579,72 @@ |
650 | namespace |
651 | { |
652 | |
653 | -ACTION_P(FillPlatformDataWith, sample_data) |
654 | -{ |
655 | - for (auto d : sample_data) |
656 | - arg1->mutable_platform()->add_data(d); |
657 | -} |
658 | - |
659 | -} |
660 | - |
661 | -TEST_F(MirConnectionTest, sets_extra_platform_data) |
662 | -{ |
663 | - using namespace testing; |
664 | - std::vector<int> const initial_data{0x66, 0x67, 0x68}; |
665 | - std::vector<int> const extra_data{0x11, 0x12, 0x13}; |
666 | - |
667 | - EXPECT_CALL(*mock_channel, connect(_,_)) |
668 | - .WillOnce(FillPlatformDataWith(initial_data)); |
669 | - |
670 | - MirWaitHandle *wait_handle = |
671 | - connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); |
672 | - wait_handle->wait_for_all(); |
673 | - |
674 | - MirPlatformPackage pkg; |
675 | - |
676 | - /* Check initial data */ |
677 | - connection->populate(pkg); |
678 | - |
679 | - EXPECT_EQ(initial_data.size(), static_cast<size_t>(pkg.data_items)); |
680 | - for (size_t i = 0; i < initial_data.size(); i++) |
681 | - EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; |
682 | - |
683 | - /* Check initial data plus extra data*/ |
684 | - connection->set_extra_platform_data(extra_data); |
685 | - connection->populate(pkg); |
686 | - |
687 | - EXPECT_EQ(initial_data.size() + extra_data.size(), |
688 | - static_cast<size_t>(pkg.data_items)); |
689 | - |
690 | - for (size_t i = 0; i < initial_data.size(); i++) |
691 | - EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; |
692 | - |
693 | - for (size_t i = 0; i < extra_data.size(); i++) |
694 | - EXPECT_EQ(extra_data[i], pkg.data[i + initial_data.size()]) << " i=" << i; |
695 | +void assign_response(MirConnection*, MirPlatformMessage* response, void* context) |
696 | +{ |
697 | + auto response_ptr = static_cast<MirPlatformMessage**>(context); |
698 | + *response_ptr = response; |
699 | +} |
700 | + |
701 | +ACTION(CopyRequestToResponse) |
702 | +{ |
703 | + *arg1 = *arg0; |
704 | +} |
705 | +} |
706 | + |
707 | +TEST_F(MirConnectionTest, uses_client_platform_for_platform_operation) |
708 | +{ |
709 | + using namespace testing; |
710 | + |
711 | + unsigned int const opcode{42}; |
712 | + auto const request = mir::raii::deleter_for( |
713 | + mir_platform_message_create(opcode), |
714 | + &mir_platform_message_release); |
715 | + auto const response = mir::raii::deleter_for( |
716 | + mir_platform_message_create(opcode), |
717 | + &mir_platform_message_release); |
718 | + |
719 | + EXPECT_CALL(*mock_platform, platform_operation(request.get())) |
720 | + .WillOnce(Return(response.get())); |
721 | + EXPECT_CALL(*mock_channel, platform_operation(_,_)) |
722 | + .Times(0); |
723 | + |
724 | + auto connect_wh = |
725 | + connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); |
726 | + mir_wait_for(connect_wh); |
727 | + |
728 | + MirPlatformMessage* returned_response{nullptr}; |
729 | + |
730 | + auto op_wh = connection->platform_operation( |
731 | + opcode, request.get(), assign_response, &returned_response); |
732 | + mir_wait_for(op_wh); |
733 | + |
734 | + EXPECT_THAT(returned_response, Eq(response.get())); |
735 | +} |
736 | + |
737 | +TEST_F(MirConnectionTest, contacts_server_if_client_platform_cannot_handle_platform_operation) |
738 | +{ |
739 | + using namespace testing; |
740 | + |
741 | + unsigned int const opcode{42}; |
742 | + auto const request = mir::raii::deleter_for( |
743 | + mir_platform_message_create(opcode), |
744 | + &mir_platform_message_release); |
745 | + |
746 | + EXPECT_CALL(*mock_platform, platform_operation(_)) |
747 | + .WillOnce(Return(nullptr)); |
748 | + EXPECT_CALL(*mock_channel, platform_operation(_,_)) |
749 | + .WillOnce(CopyRequestToResponse()); |
750 | + |
751 | + auto connect_wh = |
752 | + connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); |
753 | + mir_wait_for(connect_wh); |
754 | + |
755 | + MirPlatformMessage* returned_response{nullptr}; |
756 | + |
757 | + auto op_wh = connection->platform_operation( |
758 | + opcode, request.get(), assign_response, &returned_response); |
759 | + mir_wait_for(op_wh); |
760 | + |
761 | + EXPECT_THAT(mir_platform_message_get_opcode(returned_response), Eq(opcode)); |
762 | + mir_platform_message_release(returned_response); |
763 | } |
FAILED: Continuous integration, rev:2280 jenkins. qa.ubuntu. com/job/ mir-ci/ 2863/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/1137 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/1136/ console jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/1098 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 860 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 860/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1098 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1098/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/4151 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 17634
http://
Executed test runs:
SUCCESS: http://
FAILURE: 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/2863/ rebuild
http://