|
10 | 10 | #include <capnp/rpc.h> |
11 | 11 | #include <condition_variable> |
12 | 12 | #include <cstring> |
13 | | -#include <exception> |
14 | 13 | #include <functional> |
15 | 14 | #include <future> |
16 | | -#include <iostream> |
17 | 15 | #include <kj/async.h> |
18 | 16 | #include <kj/async-io.h> |
19 | 17 | #include <kj/common.h> |
|
24 | 22 | #include <kj/test.h> |
25 | 23 | #include <memory> |
26 | 24 | #include <mp/proxy.h> |
27 | | -#include "mp/proxy.capnp.h" |
| 25 | +#include <mp/proxy.capnp.h> |
28 | 26 | #include <mp/proxy-io.h> |
29 | | -#include "mp/util.h" |
| 27 | +#include <mp/util.h> |
30 | 28 | #include <optional> |
31 | 29 | #include <set> |
32 | 30 | #include <stdexcept> |
33 | 31 | #include <string> |
34 | 32 | #include <string_view> |
| 33 | +#include <system_error> |
35 | 34 | #include <thread> |
36 | 35 | #include <utility> |
37 | 36 | #include <vector> |
@@ -67,9 +66,10 @@ class TestSetup |
67 | 66 |
|
68 | 67 | TestSetup(bool client_owns_connection = true) |
69 | 68 | : thread{[&] { |
70 | | - EventLoop loop("mptest", [](mp::LogMessage log_data) { |
71 | | - std::cout << "LOG" << (int)log_data.level << ": " << log_data.message << "\n"; |
72 | | - if (log_data.level == mp::Log::Raise) throw std::runtime_error(log_data.message); |
| 69 | + EventLoop loop("mptest", [](mp::LogMessage log) { |
| 70 | + // Info logs are not printed by default, but will be shown with `mptest --verbose` |
| 71 | + KJ_LOG(INFO, log.level, log.message); |
| 72 | + if (log.level == mp::Log::Raise) throw std::runtime_error(log.message); |
73 | 73 | }); |
74 | 74 | auto pipe = loop.m_io_context.provider->newTwoWayPipe(); |
75 | 75 |
|
@@ -321,21 +321,21 @@ KJ_TEST("Make simultaneous IPC callbacks with same request_thread and callback_t |
321 | 321 | setup.server->m_impl->m_fn = [&] {}; |
322 | 322 | foo->callFnAsync(); |
323 | 323 | ThreadContext& tc{g_thread_context}; |
324 | | - std::optional<Thread::Client> callback_thread, request_thread; |
325 | | - { |
| 324 | + Thread::Client *callback_thread, *request_thread; |
| 325 | + foo->m_context.loop->sync([&] { |
326 | 326 | Lock lock(tc.waiter->m_mutex); |
327 | | - callback_thread = tc.callback_threads.at(foo->m_context.connection)->m_client; |
328 | | - request_thread = tc.request_threads.at(foo->m_context.connection)->m_client; |
329 | | - } |
| 327 | + callback_thread = &tc.callback_threads.at(foo->m_context.connection)->m_client; |
| 328 | + request_thread = &tc.request_threads.at(foo->m_context.connection)->m_client; |
| 329 | + }); |
330 | 330 |
|
331 | 331 | setup.server->m_impl->m_fn = [&] { |
332 | 332 | try |
333 | 333 | { |
334 | 334 | signal.get_future().get(); |
335 | 335 | } |
336 | | - catch(const std::exception& e) |
| 336 | + catch (const std::future_error& e) |
337 | 337 | { |
338 | | - KJ_EXPECT(e.what() == std::string("Future already retrieved")); |
| 338 | + KJ_EXPECT(e.code() == std::make_error_code(std::future_errc::future_already_retrieved)); |
339 | 339 | } |
340 | 340 | }; |
341 | 341 |
|
|
0 commit comments