Mir

Merge lp:~kdub/mir/fix-1487967 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 2872
Proposed branch: lp:~kdub/mir/fix-1487967
Merge into: lp:mir
Diff against target: 63 lines (+27/-16)
1 file modified
tests/integration-tests/test_exchange_buffer.cpp (+27/-16)
To merge this branch: bzr merge lp:~kdub/mir/fix-1487967
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Review via email: mp+268908@code.launchpad.net

Commit message

correct lp: #1487967 by ensuring we send our expected buffer after the initial buffers arrive.

Description of the change

correct lp: #1487967 by ensuring we send our expected buffer after the initial buffers arrive.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Nit:

11 +bool spin_wait_for_id(mg::BufferID id, MirSurface* surface, std::chrono::time_point<Clock> const& pt)

We already have mt::spin_wait_for_condition_or_timeout() in mir/test/spin_wait.h

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

OK, but like Alexandros says we already have a spinwait utility

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/integration-tests/test_exchange_buffer.cpp'
2--- tests/integration-tests/test_exchange_buffer.cpp 2015-07-28 20:51:25 +0000
3+++ tests/integration-tests/test_exchange_buffer.cpp 2015-08-24 13:12:36 +0000
4@@ -413,32 +413,43 @@
5 mir_connection_release(connection);
6 }
7
8+namespace
9+{
10+template<class Clock>
11+bool spin_wait_for_id(mg::BufferID id, MirSurface* surface, std::chrono::time_point<Clock> const& pt)
12+{
13+ while(Clock::now() < pt)
14+ {
15+ if (mir_debug_surface_current_buffer_id(surface) == id.as_value())
16+ return true;
17+ std::this_thread::yield();
18+ }
19+ return false;
20+}
21+}
22+
23 TEST_F(ExchangeBufferTest, server_can_send_buffer)
24 {
25 using namespace testing;
26 using namespace std::literals::chrono_literals;
27- mtd::StubBuffer stub_buffer;
28 auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
29 auto surface = mtf::make_any_surface(connection);
30 auto sink = server_configuration.coordinator->last_sink.lock();
31- sink->send_buffer(mf::BufferStreamId{0}, stub_buffer, mg::BufferIpcMsgType::full_msg);
32+
33+ //first wait for the last id in the exchange sequence to be seen. Avoids lp: #1487967, where
34+ //the stub sink could send before the server sends its sequence.
35+ auto timeout = std::chrono::steady_clock::now() + 5s;
36+ EXPECT_TRUE(spin_wait_for_id(buffer_id_exchange_seq.back(), surface, timeout))
37+ << "failed to see the last scheduled buffer become the current one";
38
39 //spin-wait for the id to become the current one.
40 //The notification doesn't generate a client-facing callback on the stream yet
41- //(although probably should, seems something a media decoder would need
42- bool buffer_arrived = false;
43- auto timeout = std::chrono::steady_clock::now() + 5s;
44- while(!buffer_arrived && std::chrono::steady_clock::now() < timeout)
45- {
46- mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
47- if (mir_debug_surface_current_buffer_id(surface) == stub_buffer.id().as_value())
48- {
49- buffer_arrived = true;
50- break;
51- }
52- std::this_thread::yield();
53- }
54- EXPECT_THAT(buffer_arrived, Eq(true)) << "failed to see the sent buffer become the current one";
55+ //(although probably should, seems like something a media decoder would need)
56+ mtd::StubBuffer stub_buffer;
57+ timeout = std::chrono::steady_clock::now() + 5s;
58+ sink->send_buffer(mf::BufferStreamId{0}, stub_buffer, mg::BufferIpcMsgType::full_msg);
59+ EXPECT_TRUE(spin_wait_for_id(stub_buffer.id(), surface, timeout))
60+ << "failed to see the sent buffer become the current one";
61
62 mir_surface_release_sync(surface);
63 mir_connection_release(connection);

Subscribers

People subscribed via source and target branches