Merge lp:~afrantzis/mir/remove-set-gbm-device-nested into lp:mir
- remove-set-gbm-device-nested
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alexandros Frantzis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2298 |
Proposed branch: | lp:~afrantzis/mir/remove-set-gbm-device-nested |
Merge into: | lp:mir |
Prerequisite: | lp:~afrantzis/mir/platform-operation-set-gbm-device |
Diff against target: |
623 lines (+162/-105) 17 files modified
src/client/mir_connection_api.cpp (+11/-6) src/include/platform/mir/graphics/nested_context.h (+0/-1) src/platforms/mesa/client/client_platform.cpp (+6/-5) src/platforms/mesa/server/guest_platform.cpp (+48/-19) src/platforms/mesa/server/guest_platform.h (+1/-1) src/platforms/mesa/server/ipc_operations.cpp (+10/-9) src/platforms/mesa/server/nested_authentication.cpp (+10/-9) src/server/frontend/session_mediator.cpp (+8/-7) src/server/graphics/nested/mir_client_host_connection.cpp (+0/-10) src/server/graphics/nested/mir_client_host_connection.h (+0/-1) tests/include/mir_test_doubles/mock_nested_context.h (+15/-1) tests/include/mir_test_doubles/stub_host_connection.h (+0/-1) tests/integration-tests/test_drm_auth_magic.cpp (+5/-3) tests/unit-tests/client/mesa/test_client_platform.cpp (+12/-5) tests/unit-tests/graphics/mesa/test_guest_platform.cpp (+22/-1) tests/unit-tests/graphics/mesa/test_ipc_operations.cpp (+5/-3) tests/unit-tests/graphics/mesa/test_nested_authentication.cpp (+9/-23) |
To merge this branch: | bzr merge lp:~afrantzis/mir/remove-set-gbm-device-nested |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Kevin DuBois (community) | Approve | ||
Alan Griffiths | Approve | ||
Daniel van Vugt | Pending | ||
Review via email: mp+248337@code.launchpad.net |
This proposal supersedes a proposal from 2015-02-02.
Commit message
nested: Replace drm_set_gbm_device calls with platform_operation calls
Description of the change
nested: Replace drm_set_gbm_device calls with platform_operation calls
This MP removes the last instance of a platform-dependent API from the nested server.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Targeting the wrong branch now. Somehow!?
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2283
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:
http://
Alan Griffiths (alan-griffiths) wrote : | # |
244 + auto request_ptr = reinterpret_
245 + request_
Here and elsewhere you're reinterpret_casting data allocated with a uint8_t alignment to structure that needs stricter alignment (e.g. int or type*). That isn't safe (and even on processors where it is "safe" can be very inefficient.
Alexandros Frantzis (afrantzis) wrote : | # |
Failure seems unrelated. Rebuilding.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2283
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://
Alexandros Frantzis (afrantzis) wrote : | # |
> 244 + auto request_ptr = reinterpret_
> 245 + request_
>
> Here and elsewhere you're reinterpret_casting data allocated with a uint8_t alignment to structure > that needs stricter alignment (e.g. int or type*). That isn't safe (and even on processors where it > is "safe" can be very inefficient.
Fixed. I also fixed instances of this issue introduced by earlier branches.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2284
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) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2285
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_api.cpp' |
2 | --- src/client/mir_connection_api.cpp 2015-02-03 18:51:02 +0000 |
3 | +++ src/client/mir_connection_api.cpp 2015-02-04 15:02:31 +0000 |
4 | @@ -346,9 +346,12 @@ |
5 | static_cast<AuthMagicPlatformOperationContext*>(context)}; |
6 | |
7 | auto response_data = mir_platform_message_get_data(response_msg.get()); |
8 | - auto auth_response = reinterpret_cast<MirMesaAuthMagicResponse const*>(response_data.data); |
9 | - |
10 | - auth_magic_context->callback(auth_response->status, auth_magic_context->context); |
11 | + MirMesaAuthMagicResponse auth_response{-1}; |
12 | + |
13 | + if (response_data.size == sizeof(auth_response)) |
14 | + std::memcpy(&auth_response, response_data.data, response_data.size); |
15 | + |
16 | + auth_magic_context->callback(auth_response.status, auth_magic_context->context); |
17 | } |
18 | |
19 | void assign_set_gbm_device_status( |
20 | @@ -359,11 +362,13 @@ |
21 | &mir_platform_message_release); |
22 | |
23 | auto const response_data = mir_platform_message_get_data(response_msg.get()); |
24 | - auto const set_gbm_device_response_ptr = |
25 | - reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); |
26 | + MirMesaSetGBMDeviceResponse set_gbm_device_response{-1}; |
27 | + |
28 | + if (response_data.size == sizeof(set_gbm_device_response)) |
29 | + std::memcpy(&set_gbm_device_response, response_data.data, response_data.size); |
30 | |
31 | auto status_ptr = static_cast<int*>(context); |
32 | - *status_ptr = set_gbm_device_response_ptr->status; |
33 | + *status_ptr = set_gbm_device_response.status; |
34 | } |
35 | |
36 | } |
37 | |
38 | === modified file 'src/include/platform/mir/graphics/nested_context.h' |
39 | --- src/include/platform/mir/graphics/nested_context.h 2015-02-02 12:18:18 +0000 |
40 | +++ src/include/platform/mir/graphics/nested_context.h 2015-02-04 15:02:31 +0000 |
41 | @@ -35,7 +35,6 @@ |
42 | virtual ~NestedContext() = default; |
43 | |
44 | virtual std::vector<int> platform_fd_items() = 0; |
45 | - virtual void drm_set_gbm_device(struct gbm_device* dev) = 0; |
46 | virtual PlatformOperationMessage platform_operation( |
47 | unsigned int op, PlatformOperationMessage const& request) = 0; |
48 | |
49 | |
50 | === modified file 'src/platforms/mesa/client/client_platform.cpp' |
51 | --- src/platforms/mesa/client/client_platform.cpp 2015-02-03 15:07:44 +0000 |
52 | +++ src/platforms/mesa/client/client_platform.cpp 2015-02-04 15:02:31 +0000 |
53 | @@ -136,14 +136,15 @@ |
54 | MirPlatformMessage const* msg) |
55 | { |
56 | auto const op = mir_platform_message_get_opcode(msg); |
57 | + auto const msg_data = mir_platform_message_get_data(msg); |
58 | |
59 | - if (op == MirMesaPlatformOperation::set_gbm_device) |
60 | + if (op == MirMesaPlatformOperation::set_gbm_device && |
61 | + msg_data.size == sizeof(MirMesaSetGBMDeviceRequest)) |
62 | { |
63 | - auto const msg_data = mir_platform_message_get_data(msg); |
64 | - auto const set_gbm_device_request_ptr = |
65 | - reinterpret_cast<MirMesaSetGBMDeviceRequest const*>(msg_data.data); |
66 | + MirMesaSetGBMDeviceRequest set_gbm_device_request{nullptr}; |
67 | + std::memcpy(&set_gbm_device_request, msg_data.data, msg_data.size); |
68 | |
69 | - gbm_dev = set_gbm_device_request_ptr->device; |
70 | + gbm_dev = set_gbm_device_request.device; |
71 | |
72 | static int const success{0}; |
73 | MirMesaSetGBMDeviceResponse const response{success}; |
74 | |
75 | === modified file 'src/platforms/mesa/server/guest_platform.cpp' |
76 | --- src/platforms/mesa/server/guest_platform.cpp 2015-01-22 09:00:14 +0000 |
77 | +++ src/platforms/mesa/server/guest_platform.cpp 2015-02-04 15:02:31 +0000 |
78 | @@ -19,32 +19,67 @@ |
79 | */ |
80 | |
81 | #include "guest_platform.h" |
82 | - |
83 | +#include "nested_authentication.h" |
84 | +#include "ipc_operations.h" |
85 | #include "buffer_allocator.h" |
86 | -#include "mir/graphics/buffer_ipc_message.h" |
87 | -#include "mir/graphics/platform_ipc_package.h" |
88 | + |
89 | #include "mir/graphics/nested_context.h" |
90 | - |
91 | -#include "nested_authentication.h" |
92 | - |
93 | -#include "ipc_operations.h" |
94 | +#include "mir/graphics/platform_operation_message.h" |
95 | +#include "mir_toolkit/mesa/platform_operation.h" |
96 | |
97 | #include <boost/exception/errinfo_errno.hpp> |
98 | #include <boost/throw_exception.hpp> |
99 | |
100 | #include <mutex> |
101 | #include <stdexcept> |
102 | +#include <cstring> |
103 | |
104 | namespace mg = mir::graphics; |
105 | namespace mgm = mg::mesa; |
106 | |
107 | -mgm::GuestPlatform::GuestPlatform(std::shared_ptr<NestedContext> const& nested_context_arg) |
108 | -{ |
109 | - //TODO: a bit of round-about initialization to clean up here |
110 | - nested_context = nested_context_arg; |
111 | - auto fds = nested_context->platform_fd_items(); |
112 | +namespace |
113 | +{ |
114 | + |
115 | +void set_guest_gbm_device(mg::NestedContext& nested_context, gbm_device* gbm_dev) |
116 | +{ |
117 | + MirMesaSetGBMDeviceRequest const request{gbm_dev}; |
118 | + mg::PlatformOperationMessage request_msg; |
119 | + request_msg.data.resize(sizeof(MirMesaSetGBMDeviceRequest)); |
120 | + std::memcpy(request_msg.data.data(), &request, sizeof(request)); |
121 | + |
122 | + auto const response_msg = nested_context.platform_operation( |
123 | + MirMesaPlatformOperation::set_gbm_device, |
124 | + request_msg); |
125 | + |
126 | + if (response_msg.data.size() == sizeof(MirMesaSetGBMDeviceResponse)) |
127 | + { |
128 | + static int const success{0}; |
129 | + MirMesaSetGBMDeviceResponse response{-1}; |
130 | + std::memcpy(&response, response_msg.data.data(), response_msg.data.size()); |
131 | + if (response.status != success) |
132 | + { |
133 | + std::string const msg{"Nested Mir failed to set the gbm device."}; |
134 | + BOOST_THROW_EXCEPTION( |
135 | + boost::enable_error_info(std::runtime_error(msg)) |
136 | + << boost::errinfo_errno(response.status)); |
137 | + } |
138 | + } |
139 | + else |
140 | + { |
141 | + std::string const msg{"Nested Mir failed to set the gbm device: Invalid response."}; |
142 | + BOOST_THROW_EXCEPTION(std::runtime_error(msg)); |
143 | + } |
144 | +} |
145 | + |
146 | +} |
147 | + |
148 | +mgm::GuestPlatform::GuestPlatform( |
149 | + std::shared_ptr<NestedContext> const& nested_context) |
150 | + : nested_context{nested_context} |
151 | +{ |
152 | + auto const fds = nested_context->platform_fd_items(); |
153 | gbm.setup(fds.at(0)); |
154 | - nested_context->drm_set_gbm_device(gbm.device); |
155 | + set_guest_gbm_device(*nested_context, gbm.device); |
156 | ipc_ops = std::make_shared<mgm::IpcOperations>( |
157 | std::make_shared<mgm::NestedAuthentication>(nested_context)); |
158 | } |
159 | @@ -61,12 +96,6 @@ |
160 | return std::make_shared<mgm::GuestPlatform>(nested_context); |
161 | } |
162 | |
163 | -namespace |
164 | -{ |
165 | -std::shared_ptr<mgm::InternalNativeDisplay> native_display = nullptr; |
166 | -std::mutex native_display_guard; |
167 | -} |
168 | - |
169 | std::shared_ptr<mg::PlatformIpcOperations> mgm::GuestPlatform::make_ipc_operations() const |
170 | { |
171 | return ipc_ops; |
172 | |
173 | === modified file 'src/platforms/mesa/server/guest_platform.h' |
174 | --- src/platforms/mesa/server/guest_platform.h 2015-01-22 09:00:14 +0000 |
175 | +++ src/platforms/mesa/server/guest_platform.h 2015-02-04 15:02:31 +0000 |
176 | @@ -48,7 +48,7 @@ |
177 | EGLNativeDisplayType egl_native_display() const override; |
178 | |
179 | private: |
180 | - std::shared_ptr<NestedContext> nested_context; |
181 | + std::shared_ptr<NestedContext> const nested_context; |
182 | helpers::GBMHelper gbm; |
183 | std::shared_ptr<PlatformIpcOperations> ipc_ops; |
184 | }; |
185 | |
186 | === modified file 'src/platforms/mesa/server/ipc_operations.cpp' |
187 | --- src/platforms/mesa/server/ipc_operations.cpp 2015-02-02 12:18:18 +0000 |
188 | +++ src/platforms/mesa/server/ipc_operations.cpp 2015-02-04 15:02:31 +0000 |
189 | @@ -31,6 +31,8 @@ |
190 | #include <boost/exception/get_error_info.hpp> |
191 | #include <boost/exception/errinfo_errno.hpp> |
192 | |
193 | +#include <cstring> |
194 | + |
195 | namespace mg = mir::graphics; |
196 | namespace mgm = mir::graphics::mesa; |
197 | |
198 | @@ -89,8 +91,7 @@ |
199 | MirMesaAuthMagicRequest auth_magic_request; |
200 | if (request.data.size() == sizeof(auth_magic_request)) |
201 | { |
202 | - auth_magic_request = |
203 | - *reinterpret_cast<decltype(auth_magic_request) const*>(request.data.data()); |
204 | + std::memcpy(&auth_magic_request, request.data.data(), request.data.size()); |
205 | } |
206 | else |
207 | { |
208 | @@ -98,27 +99,27 @@ |
209 | std::runtime_error("Invalid request message for auth_magic platform operation")); |
210 | } |
211 | |
212 | - mg::PlatformOperationMessage response; |
213 | - response.data.resize(sizeof(MirMesaAuthMagicResponse)); |
214 | - auto const auth_magic_response_ptr = |
215 | - reinterpret_cast<MirMesaAuthMagicResponse*>(response.data.data()); |
216 | + MirMesaAuthMagicResponse auth_magic_response{-1}; |
217 | |
218 | try |
219 | { |
220 | drm_auth->auth_magic(auth_magic_request.magic); |
221 | - auth_magic_response_ptr->status = 0; |
222 | + auth_magic_response.status = 0; |
223 | } |
224 | catch (std::exception const& e) |
225 | { |
226 | auto errno_ptr = boost::get_error_info<boost::errinfo_errno>(e); |
227 | |
228 | if (errno_ptr != nullptr) |
229 | - auth_magic_response_ptr->status = *errno_ptr; |
230 | + auth_magic_response.status = *errno_ptr; |
231 | else |
232 | throw; |
233 | } |
234 | |
235 | - return response; |
236 | + mg::PlatformOperationMessage response_msg; |
237 | + response_msg.data.resize(sizeof(auth_magic_response)); |
238 | + std::memcpy(response_msg.data.data(), &auth_magic_response, sizeof(auth_magic_response)); |
239 | + return response_msg; |
240 | } |
241 | else if (op == MirMesaPlatformOperation::auth_fd) |
242 | { |
243 | |
244 | === modified file 'src/platforms/mesa/server/nested_authentication.cpp' |
245 | --- src/platforms/mesa/server/nested_authentication.cpp 2015-02-02 12:18:18 +0000 |
246 | +++ src/platforms/mesa/server/nested_authentication.cpp 2015-02-04 15:02:31 +0000 |
247 | @@ -25,6 +25,8 @@ |
248 | #include <boost/exception/errinfo_errno.hpp> |
249 | #include <boost/throw_exception.hpp> |
250 | |
251 | +#include <cstring> |
252 | + |
253 | namespace mg = mir::graphics; |
254 | namespace mgm = mir::graphics::mesa; |
255 | |
256 | @@ -33,12 +35,11 @@ |
257 | |
258 | mg::PlatformOperationMessage make_auth_magic_request_message(drm_magic_t magic) |
259 | { |
260 | - mg::PlatformOperationMessage request; |
261 | - request.data.resize(sizeof(MirMesaAuthMagicRequest)); |
262 | - auto auth_magic_request_ptr = |
263 | - reinterpret_cast<MirMesaAuthMagicRequest*>(request.data.data()); |
264 | - auth_magic_request_ptr->magic = magic; |
265 | - return request; |
266 | + MirMesaAuthMagicRequest const request{magic}; |
267 | + mg::PlatformOperationMessage request_msg; |
268 | + request_msg.data.resize(sizeof(request)); |
269 | + std::memcpy(request_msg.data.data(), &request, sizeof(request)); |
270 | + return request_msg; |
271 | } |
272 | |
273 | MirMesaAuthMagicResponse auth_magic_response_from_message( |
274 | @@ -46,10 +47,10 @@ |
275 | { |
276 | if (msg.data.size() == sizeof(MirMesaAuthMagicResponse)) |
277 | { |
278 | - auto auth_magic_response_ptr = |
279 | - reinterpret_cast<MirMesaAuthMagicResponse const*>(msg.data.data()); |
280 | + MirMesaAuthMagicResponse response{-1}; |
281 | + std::memcpy(&response, msg.data.data(), msg.data.size()); |
282 | |
283 | - return *auth_magic_response_ptr; |
284 | + return response; |
285 | } |
286 | |
287 | BOOST_THROW_EXCEPTION( |
288 | |
289 | === modified file 'src/server/frontend/session_mediator.cpp' |
290 | --- src/server/frontend/session_mediator.cpp 2015-02-02 12:18:18 +0000 |
291 | +++ src/server/frontend/session_mediator.cpp 2015-02-04 15:02:31 +0000 |
292 | @@ -61,6 +61,7 @@ |
293 | |
294 | #include <mutex> |
295 | #include <functional> |
296 | +#include <cstring> |
297 | |
298 | namespace ms = mir::scene; |
299 | namespace mf = mir::frontend; |
300 | @@ -636,18 +637,18 @@ |
301 | |
302 | auto const magic = request->magic(); |
303 | |
304 | + MirMesaAuthMagicRequest const auth_magic_request{magic}; |
305 | mg::PlatformOperationMessage platform_request; |
306 | - platform_request.data.resize(sizeof(MirMesaAuthMagicRequest)); |
307 | - auto const auth_magic_request_ptr = |
308 | - reinterpret_cast<MirMesaAuthMagicRequest*>(platform_request.data.data()); |
309 | - *auth_magic_request_ptr = MirMesaAuthMagicRequest{magic}; |
310 | + platform_request.data.resize(sizeof(auth_magic_request)); |
311 | + std::memcpy(platform_request.data.data(), &auth_magic_request, sizeof(auth_magic_request)); |
312 | |
313 | auto const platform_response = ipc_operations->platform_operation( |
314 | MirMesaPlatformOperation::auth_magic, platform_request); |
315 | |
316 | - auto const auth_magic_response_ptr = |
317 | - reinterpret_cast<MirMesaAuthMagicResponse const*>(platform_response.data.data()); |
318 | - response->set_status_code(auth_magic_response_ptr->status); |
319 | + MirMesaAuthMagicResponse auth_magic_response{-1}; |
320 | + std::memcpy(&auth_magic_response, platform_response.data.data(), |
321 | + platform_response.data.size()); |
322 | + response->set_status_code(auth_magic_response.status); |
323 | |
324 | done->Run(); |
325 | } |
326 | |
327 | === modified file 'src/server/graphics/nested/mir_client_host_connection.cpp' |
328 | --- src/server/graphics/nested/mir_client_host_connection.cpp 2015-02-03 18:51:02 +0000 |
329 | +++ src/server/graphics/nested/mir_client_host_connection.cpp 2015-02-04 15:02:31 +0000 |
330 | @@ -18,7 +18,6 @@ |
331 | |
332 | #include "mir_client_host_connection.h" |
333 | #include "mir_toolkit/mir_client_library.h" |
334 | -#include "mir_toolkit/mir_client_library_drm.h" |
335 | #include "mir/raii.h" |
336 | #include "mir/graphics/platform_operation_message.h" |
337 | |
338 | @@ -163,15 +162,6 @@ |
339 | mir_connection, surface_parameters); |
340 | } |
341 | |
342 | -void mgn::MirClientHostConnection::drm_set_gbm_device(struct gbm_device* dev) |
343 | -{ |
344 | - if (!mir_connection_drm_set_gbm_device(mir_connection, dev)) |
345 | - { |
346 | - std::string const msg("Nested Mir failed to set the gbm device"); |
347 | - BOOST_THROW_EXCEPTION(std::runtime_error(msg)); |
348 | - } |
349 | -} |
350 | - |
351 | mg::PlatformOperationMessage mgn::MirClientHostConnection::platform_operation( |
352 | unsigned int op, mg::PlatformOperationMessage const& request) |
353 | { |
354 | |
355 | === modified file 'src/server/graphics/nested/mir_client_host_connection.h' |
356 | --- src/server/graphics/nested/mir_client_host_connection.h 2015-02-02 12:18:18 +0000 |
357 | +++ src/server/graphics/nested/mir_client_host_connection.h 2015-02-04 15:02:31 +0000 |
358 | @@ -48,7 +48,6 @@ |
359 | void set_display_config_change_callback(std::function<void()> const& cb) override; |
360 | void apply_display_config(MirDisplayConfiguration&) override; |
361 | |
362 | - void drm_set_gbm_device(struct gbm_device* dev) override; |
363 | virtual PlatformOperationMessage platform_operation( |
364 | unsigned int op, PlatformOperationMessage const& request) override; |
365 | |
366 | |
367 | === modified file 'tests/include/mir_test_doubles/mock_nested_context.h' |
368 | --- tests/include/mir_test_doubles/mock_nested_context.h 2015-01-26 15:53:18 +0000 |
369 | +++ tests/include/mir_test_doubles/mock_nested_context.h 2015-02-04 15:02:31 +0000 |
370 | @@ -24,6 +24,21 @@ |
371 | |
372 | namespace mir |
373 | { |
374 | +namespace graphics |
375 | +{ |
376 | +inline bool operator==(PlatformOperationMessage const& msg1, |
377 | + PlatformOperationMessage const& msg2) |
378 | +{ |
379 | + return msg1.data == msg2.data && msg1.fds == msg2.fds; |
380 | +} |
381 | + |
382 | +inline bool operator!=(PlatformOperationMessage const& msg1, |
383 | + PlatformOperationMessage const& msg2) |
384 | +{ |
385 | + return !(msg1 == msg2); |
386 | +} |
387 | +} |
388 | + |
389 | namespace test |
390 | { |
391 | namespace doubles |
392 | @@ -33,7 +48,6 @@ |
393 | { |
394 | MOCK_METHOD0(platform_fd_items, std::vector<int>()); |
395 | MOCK_METHOD1(drm_auth_magic, void(int magic)); |
396 | - MOCK_METHOD1(drm_set_gbm_device, void(struct gbm_device* dev)); |
397 | MOCK_METHOD2(platform_operation, graphics::PlatformOperationMessage( |
398 | unsigned int, graphics::PlatformOperationMessage const&)); |
399 | }; |
400 | |
401 | === modified file 'tests/include/mir_test_doubles/stub_host_connection.h' |
402 | --- tests/include/mir_test_doubles/stub_host_connection.h 2015-01-26 15:53:18 +0000 |
403 | +++ tests/include/mir_test_doubles/stub_host_connection.h 2015-02-04 15:02:31 +0000 |
404 | @@ -61,7 +61,6 @@ |
405 | return std::make_shared<NullHostSurface>(); |
406 | } |
407 | |
408 | - void drm_set_gbm_device(struct gbm_device*) override {} |
409 | graphics::PlatformOperationMessage platform_operation( |
410 | unsigned int, graphics::PlatformOperationMessage const&) override |
411 | { |
412 | |
413 | === modified file 'tests/integration-tests/test_drm_auth_magic.cpp' |
414 | --- tests/integration-tests/test_drm_auth_magic.cpp 2015-02-02 12:18:18 +0000 |
415 | +++ tests/integration-tests/test_drm_auth_magic.cpp 2015-02-04 15:02:31 +0000 |
416 | @@ -35,6 +35,8 @@ |
417 | #include <gmock/gmock.h> |
418 | #include <gtest/gtest.h> |
419 | |
420 | +#include <cstring> |
421 | + |
422 | namespace mg = mir::graphics; |
423 | namespace mc = mir::compositor; |
424 | namespace geom = mir::geometry; |
425 | @@ -102,9 +104,9 @@ |
426 | if (!platform) |
427 | { |
428 | mg::PlatformOperationMessage pkg; |
429 | - pkg.data.resize(sizeof(MirMesaAuthMagicResponse)); |
430 | - *(reinterpret_cast<MirMesaAuthMagicResponse*>(pkg.data.data())) = |
431 | - auth_magic_response; |
432 | + pkg.data.resize(sizeof(auth_magic_response)); |
433 | + std::memcpy(pkg.data.data(), &auth_magic_response, |
434 | + sizeof(auth_magic_response)); |
435 | |
436 | auto ipc_ops = std::make_shared<NiceMock<MockAuthenticatingIpcOps>>(); |
437 | EXPECT_CALL(*ipc_ops, platform_operation(_,_)) |
438 | |
439 | === modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp' |
440 | --- tests/unit-tests/client/mesa/test_client_platform.cpp 2015-02-03 15:07:44 +0000 |
441 | +++ tests/unit-tests/client/mesa/test_client_platform.cpp 2015-02-04 15:02:31 +0000 |
442 | @@ -29,6 +29,8 @@ |
443 | #include <gtest/gtest.h> |
444 | #include <gmock/gmock.h> |
445 | |
446 | +#include <cstring> |
447 | + |
448 | namespace mcl = mir::client; |
449 | namespace mclm = mir::client::mesa; |
450 | namespace mtf = mir_test_framework; |
451 | @@ -95,9 +97,10 @@ |
452 | ASSERT_THAT(response_msg, NotNull()); |
453 | auto const response_data = mir_platform_message_get_data(response_msg.get()); |
454 | ASSERT_THAT(response_data.size, Eq(sizeof(MirMesaSetGBMDeviceResponse))); |
455 | - auto const response_ptr = |
456 | - reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); |
457 | - EXPECT_THAT(response_ptr->status, Eq(success)); |
458 | + |
459 | + MirMesaSetGBMDeviceResponse response{-1}; |
460 | + std::memcpy(&response, response_data.data, response_data.size); |
461 | + EXPECT_THAT(response.status, Eq(success)); |
462 | } |
463 | |
464 | TEST_F(MesaClientPlatformTest, appends_gbm_device_to_platform_package) |
465 | @@ -115,6 +118,10 @@ |
466 | |
467 | platform->populate(pkg); |
468 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(gbm_dev_dummy) / sizeof(int)))); |
469 | - EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), |
470 | - Eq(gbm_dev_dummy)); |
471 | + |
472 | + gbm_device* device_in_package{nullptr}; |
473 | + std::memcpy(&device_in_package, &pkg.data[previous_data_count], |
474 | + sizeof(device_in_package)); |
475 | + |
476 | + EXPECT_THAT(device_in_package, Eq(gbm_dev_dummy)); |
477 | } |
478 | |
479 | === modified file 'tests/unit-tests/graphics/mesa/test_guest_platform.cpp' |
480 | --- tests/unit-tests/graphics/mesa/test_guest_platform.cpp 2015-02-02 12:18:18 +0000 |
481 | +++ tests/unit-tests/graphics/mesa/test_guest_platform.cpp 2015-02-04 15:02:31 +0000 |
482 | @@ -33,6 +33,8 @@ |
483 | #include <gtest/gtest.h> |
484 | #include <gmock/gmock.h> |
485 | |
486 | +#include <cstring> |
487 | + |
488 | namespace mg = mir::graphics; |
489 | namespace mgm = mir::graphics::mesa; |
490 | namespace mt = mir::test; |
491 | @@ -49,8 +51,17 @@ |
492 | { |
493 | using namespace testing; |
494 | |
495 | + MirMesaSetGBMDeviceResponse const response_success{0}; |
496 | + mg::PlatformOperationMessage set_gbm_device_success_msg; |
497 | + set_gbm_device_success_msg.data.resize(sizeof(response_success)); |
498 | + std::memcpy(set_gbm_device_success_msg.data.data(), |
499 | + &response_success, sizeof(response_success)); |
500 | + |
501 | ON_CALL(mock_nested_context, platform_fd_items()) |
502 | .WillByDefault(Return(std::vector<int>{mock_drm.fake_drm.fd()})); |
503 | + ON_CALL(mock_nested_context, |
504 | + platform_operation(MirMesaPlatformOperation::set_gbm_device, _)) |
505 | + .WillByDefault(Return(set_gbm_device_success_msg)); |
506 | } |
507 | |
508 | protected: |
509 | @@ -69,6 +80,8 @@ |
510 | mg::PlatformOperationMessage auth_fd_response{{},{auth_fd}}; |
511 | |
512 | EXPECT_CALL(mock_nested_context, |
513 | + platform_operation(MirMesaPlatformOperation::set_gbm_device, _)); |
514 | + EXPECT_CALL(mock_nested_context, |
515 | platform_operation(MirMesaPlatformOperation::auth_fd, _)) |
516 | .WillOnce(Return(auth_fd_response)); |
517 | |
518 | @@ -79,6 +92,14 @@ |
519 | |
520 | TEST_F(MesaGuestPlatformTest, sets_gbm_device_during_initialization) |
521 | { |
522 | - EXPECT_CALL(mock_nested_context, drm_set_gbm_device(mock_gbm.fake_gbm.device)); |
523 | + MirMesaSetGBMDeviceRequest const request{mock_gbm.fake_gbm.device}; |
524 | + mg::PlatformOperationMessage request_msg; |
525 | + request_msg.data.resize(sizeof(request)); |
526 | + std::memcpy(request_msg.data.data(), &request, sizeof(request)); |
527 | + |
528 | + EXPECT_CALL(mock_nested_context, |
529 | + platform_operation(MirMesaPlatformOperation::set_gbm_device, |
530 | + request_msg)); |
531 | + |
532 | mgm::GuestPlatform native(mt::fake_shared(mock_nested_context)); |
533 | } |
534 | |
535 | === modified file 'tests/unit-tests/graphics/mesa/test_ipc_operations.cpp' |
536 | --- tests/unit-tests/graphics/mesa/test_ipc_operations.cpp 2015-02-02 12:18:18 +0000 |
537 | +++ tests/unit-tests/graphics/mesa/test_ipc_operations.cpp 2015-02-04 15:02:31 +0000 |
538 | @@ -29,6 +29,8 @@ |
539 | #include "mir_test_doubles/mock_drm.h" |
540 | #include <gtest/gtest.h> |
541 | |
542 | +#include <cstring> |
543 | + |
544 | namespace mg = mir::graphics; |
545 | namespace mt = mir::test; |
546 | namespace mtd = mir::test::doubles; |
547 | @@ -101,14 +103,14 @@ |
548 | |
549 | mg::PlatformOperationMessage request_msg; |
550 | request_msg.data.resize(sizeof(request)); |
551 | - *(reinterpret_cast<decltype(request)*>(request_msg.data.data())) = request; |
552 | + std::memcpy(request_msg.data.data(), &request, sizeof(request)); |
553 | |
554 | auto response_msg = ipc_ops.platform_operation( |
555 | MirMesaPlatformOperation::auth_magic, request_msg); |
556 | |
557 | - MirMesaAuthMagicResponse response; |
558 | + MirMesaAuthMagicResponse response{-1}; |
559 | ASSERT_THAT(response_msg.data.size(), Eq(sizeof(response))); |
560 | - response = *(reinterpret_cast<decltype(response)*>(response_msg.data.data())); |
561 | + std::memcpy(&response, response_msg.data.data(), response_msg.data.size()); |
562 | EXPECT_THAT(response.status, Eq(0)); |
563 | } |
564 | |
565 | |
566 | === modified file 'tests/unit-tests/graphics/mesa/test_nested_authentication.cpp' |
567 | --- tests/unit-tests/graphics/mesa/test_nested_authentication.cpp 2015-02-02 12:18:18 +0000 |
568 | +++ tests/unit-tests/graphics/mesa/test_nested_authentication.cpp 2015-02-04 15:02:31 +0000 |
569 | @@ -25,6 +25,8 @@ |
570 | #include "mir_test/fake_shared.h" |
571 | #include <gtest/gtest.h> |
572 | |
573 | +#include <cstring> |
574 | + |
575 | namespace mg = mir::graphics; |
576 | namespace mgm = mir::graphics::mesa; |
577 | namespace mt = mir::test; |
578 | @@ -40,38 +42,22 @@ |
579 | }; |
580 | } |
581 | |
582 | -namespace mir |
583 | -{ |
584 | -namespace graphics |
585 | -{ |
586 | - |
587 | -bool operator==(mg::PlatformOperationMessage const& msg1, |
588 | - mg::PlatformOperationMessage const& msg2) |
589 | -{ |
590 | - return msg1.data == msg2.data && |
591 | - msg1.fds == msg1.fds; |
592 | -} |
593 | -} |
594 | - |
595 | -} |
596 | - |
597 | TEST_F(NestedAuthentication, uses_nested_context_for_auth_magic) |
598 | { |
599 | using namespace testing; |
600 | |
601 | unsigned int const magic{332211}; |
602 | |
603 | + MirMesaAuthMagicRequest const request{magic}; |
604 | mg::PlatformOperationMessage msg; |
605 | - msg.data.resize(sizeof(MirMesaAuthMagicRequest)); |
606 | - *reinterpret_cast<MirMesaAuthMagicRequest*>(msg.data.data()) = |
607 | - MirMesaAuthMagicRequest{magic}; |
608 | + msg.data.resize(sizeof(request)); |
609 | + std::memcpy(msg.data.data(), &request, sizeof(request)); |
610 | |
611 | - int const success{0}; |
612 | + MirMesaAuthMagicResponse const success_response{0}; |
613 | mg::PlatformOperationMessage auth_magic_success_response; |
614 | - auth_magic_success_response.data.resize(sizeof(MirMesaAuthMagicResponse)); |
615 | - *reinterpret_cast<MirMesaAuthMagicResponse*>( |
616 | - auth_magic_success_response.data.data()) = |
617 | - MirMesaAuthMagicResponse{success}; |
618 | + auth_magic_success_response.data.resize(sizeof(success_response)); |
619 | + std::memcpy(auth_magic_success_response.data.data(), &success_response, |
620 | + sizeof(success_response)); |
621 | |
622 | EXPECT_CALL(mock_nested_context, |
623 | platform_operation(MirMesaPlatformOperation::auth_magic, msg)) |
PASSED: Continuous integration, rev:2283 jenkins. qa.ubuntu. com/job/ mir-ci/ 2871/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/1150 jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/1149 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/1110 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 868 jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 868/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1110 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 1110/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/4163 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 17664
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/2871/ rebuild
http://