Mir

Merge lp:~mir-team/mir/port-uncooperative-tests-to-surface-spec into lp:mir

Proposed by Robert Carr
Status: Merged
Merged at revision: 2157
Proposed branch: lp:~mir-team/mir/port-uncooperative-tests-to-surface-spec
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/port-cooperative-tests-to-surface-spec
Diff against target: 124 lines (+25/-27)
3 files modified
src/client/mir_surface.cpp (+21/-2)
src/client/rpc/mir_protobuf_rpc_channel.cpp (+0/-2)
tests/acceptance-tests/test_server_disconnect.cpp (+4/-23)
To merge this branch: bzr merge lp:~mir-team/mir/port-uncooperative-tests-to-surface-spec
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Approve
Cemil Azizoglu (community) Approve
Review via email: mp+244057@code.launchpad.net

Commit message

Port uncooperative tests to surface spec by first fixing https://bugs.launchpad.net/mir/+bug/1394873

Description of the change

Port uncooperative tests to surface spec by first fixing https://bugs.launchpad.net/mir/+bug/1394873

To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote :

I'm not sure that's the right fix? Maybe it's the best we can do given protobuf's callbacks?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

19 - send_message(invocation, invocation, fds);
20 + try
21 + {
22 + send_message(invocation, invocation, fds);
23 + }
24 + // In general we propagate this exception up to the client
25 + // library so that it may invoke appropriate error callbacks,
26 + // etc...however in the case of disconnect the notify_disconnect
27 + // codepath will take care of this and we need to surpress the
28 + // exception here. (lp:1394873)
29 + catch (...)
30 + {
31 + if (!disconnected.load())
32 + throw;
33 + }

This is not really anything to do with the stated reason for this MP is it?

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

>> his is not really anything to do with the stated reason for this MP is it?

https://code.launchpad.net/bugs/1394873

Is it the branch title you'd like me to change?

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

So, fix + port. Probably wanna separate the fix out in its own MP.

For the ports, same comments apply :
https://code.launchpad.net/~mir-team/mir/port-cooperative-tests-to-surface-spec/+merge/244056/comments/601848

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Approving this. Port is ok (as mentioned in the other MP).

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> >> his is not really anything to do with the stated reason for this MP is it?
>
> https://code.launchpad.net/bugs/1394873
>
> Is it the branch title you'd like me to change?

No, just confirming my understanding

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

$ bin/mir_unit_tests --gtest_filter=MirProtobufRpcChannelTest.*
Running main() from command_line_server_configuration.cpp
Note: Google Test filter = MirProtobufRpcChannelTest.*
[==========] Running 8 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 8 tests from MirProtobufRpcChannelTest
[ RUN ] MirProtobufRpcChannelTest.ReadsFullMessages
[ OK ] MirProtobufRpcChannelTest.ReadsFullMessages (0 ms)
[ RUN ] MirProtobufRpcChannelTest.ReadsAllQueuedMessages
[ OK ] MirProtobufRpcChannelTest.ReadsAllQueuedMessages (0 ms)
[ RUN ] MirProtobufRpcChannelTest.SendsMessagesAtomically
[ OK ] MirProtobufRpcChannelTest.SendsMessagesAtomically (1 ms)
[ RUN ] MirProtobufRpcChannelTest.SetsCorrectSizeWhenSendingMessage
[ OK ] MirProtobufRpcChannelTest.SetsCorrectSizeWhenSendingMessage (0 ms)
[ RUN ] MirProtobufRpcChannelTest.ReadsFds
[ OK ] MirProtobufRpcChannelTest.ReadsFds (1 ms)
[ RUN ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnWriteError
/home/alan/display_server/mir4/tests/unit-tests/client/test_protobuf_rpc_channel.cpp:321: Failure
Expected: channel_user.exchange_buffer(nullptr, &request, &reply, google::protobuf::NewCallback([](){})) throws an exception of type std::runtime_error.
  Actual: it throws nothing.
[ FAILED ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnWriteError (0 ms)
[ RUN ] MirProtobufRpcChannelTest.ForwardsDisconnectNotification
[ OK ] MirProtobufRpcChannelTest.ForwardsDisconnectNotification (0 ms)
[ RUN ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnlyOnce
/home/alan/display_server/mir4/tests/unit-tests/client/test_protobuf_rpc_channel.cpp:382: Failure
Expected: channel_user.exchange_buffer(nullptr, &request, &reply, google::protobuf::NewCallback([](){})) throws an exception of type std::runtime_error.
  Actual: it throws nothing.
[ FAILED ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnlyOnce (1 ms)
[----------] 8 tests from MirProtobufRpcChannelTest (3 ms total)

[----------] Global test environment tear-down
[==========] 8 tests from 1 test case ran. (4 ms total)
[ PASSED ] 6 tests.
[ FAILED ] 2 tests, listed below:
[ FAILED ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnWriteError
[ FAILED ] MirProtobufRpcChannelTest.NotifiesOfDisconnectOnlyOnce

 2 FAILED TESTS

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

I think this is the right fix now...(in r2133).

In the case that send_message throws, the MirSurface constructor will now catch it and convert it in to an error. In this case the client library wont catch an exception and wont construct the duplicate error object.

The exception catch + error object creation is left in for cases where MirSurface constructor really does throw (e.g. as in the test which simulates BufferFactory throw failure).

It was necessary to make some changes in MirSurface::created to handle the pending call completion for the surface which never received a response.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/mir_surface.cpp'
2--- src/client/mir_surface.cpp 2014-12-09 03:14:55 +0000
3+++ src/client/mir_surface.cpp 2014-12-15 07:36:03 +0000
4@@ -127,7 +127,15 @@
5 message.set_output_id(params.output_id);
6
7 create_wait_handle.expect_result();
8- server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));
9+ try
10+ {
11+ server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));
12+ }
13+ catch (std::exception const& ex)
14+ {
15+ surface.set_error(std::string{"Error invoking create surface: "} +
16+ boost::diagnostic_information(ex));
17+ }
18
19 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
20 valid_surfaces.insert(this);
21@@ -283,8 +291,19 @@
22
23 void MirSurface::created(mir_surface_callback callback, void * context)
24 {
25+ {
26+ std::lock_guard<decltype(mutex)> lock(mutex);
27+ if (!surface.has_id())
28+ {
29+ if (!surface.has_error())
30+ surface.set_error("Error processing surface create response, no ID (disconnected?)");
31+ callback(this, context);
32+ create_wait_handle.result_received();
33+ return;
34+ }
35+ }
36+
37 auto platform = connection->get_client_platform();
38-
39 try
40 {
41 {
42
43=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
44--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2014-12-15 03:17:26 +0000
45+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2014-12-15 07:36:03 +0000
46@@ -82,7 +82,6 @@
47 pending_calls.force_completion();
48 }
49
50-
51 template<class MessageType>
52 void mclr::MirProtobufRpcChannel::receive_any_file_descriptors_for(MessageType* response)
53 {
54@@ -189,7 +188,6 @@
55 std::shared_ptr<google::protobuf::Closure> callback(
56 google::protobuf::NewPermanentCallback(this, &MirProtobufRpcChannel::receive_file_descriptors, response, complete));
57
58- // Only save details after serialization succeeds
59 pending_calls.save_completion_details(invocation, response, callback);
60
61 send_message(invocation, invocation, fds);
62
63=== modified file 'tests/acceptance-tests/test_server_disconnect.cpp'
64--- tests/acceptance-tests/test_server_disconnect.cpp 2014-12-08 04:03:47 +0000
65+++ tests/acceptance-tests/test_server_disconnect.cpp 2014-12-15 07:36:03 +0000
66@@ -21,6 +21,7 @@
67 #include "mir_test_framework/interprocess_client_server_test.h"
68 #include "mir_test_framework/cross_process_sync.h"
69 #include "mir_test_framework/process.h"
70+#include "mir_test_framework/any_surface.h"
71 #include "mir_test/cross_process_action.h"
72
73 #include <gtest/gtest.h>
74@@ -63,15 +64,11 @@
75
76 auto const client = new_client_process([&]
77 {
78- static MirSurfaceParameters const params =
79- { __PRETTY_FUNCTION__, 33, 45, mir_pixel_format_abgr_8888,
80- mir_buffer_usage_hardware, mir_display_output_id_invalid };
81-
82 MockEventHandler mock_event_handler;
83
84 auto connection = mir_connect_sync(mtf::test_socket_file().c_str() , __PRETTY_FUNCTION__);
85 mir_connection_set_lifecycle_event_callback(connection, &MockEventHandler::handle, &mock_event_handler);
86- auto surface = mir_connection_create_surface_sync(connection, &params);
87+ auto surface = mtf::make_any_surface(connection);
88
89 std::atomic<bool> signalled(false);
90
91@@ -125,15 +122,7 @@
92 MirSurface* surf;
93
94 create_surface.exec([&] {
95- MirSurfaceParameters const parameters =
96- {
97- __PRETTY_FUNCTION__,
98- 1, 1,
99- mir_pixel_format_abgr_8888,
100- mir_buffer_usage_hardware,
101- mir_display_output_id_invalid
102- };
103- surf = mir_connection_create_surface_sync(connection, &parameters);
104+ surf = mtf::make_any_surface(connection);
105 });
106
107 configure_display.exec([&] {
108@@ -178,15 +167,7 @@
109
110 create_surface_sync.wait_for_signal_ready_for();
111
112- MirSurfaceParameters const parameters =
113- {
114- __PRETTY_FUNCTION__,
115- 1, 1,
116- mir_pixel_format_abgr_8888,
117- mir_buffer_usage_hardware,
118- mir_display_output_id_invalid
119- };
120- mir_connection_create_surface_sync(connection, &parameters);
121+ mtf::make_any_surface(connection);
122
123 mir_connection_release(connection);
124 });

Subscribers

People subscribed via source and target branches