Test ipc::Protocol connect() and serve() methods connecting over a socketpair.
| 118 | |
| 119 | //! Test ipc::Protocol connect() and serve() methods connecting over a socketpair. |
| 120 | void IpcSocketPairTest() |
| 121 | { |
| 122 | int fds[2]; |
| 123 | BOOST_CHECK_EQUAL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds), 0); |
| 124 | std::unique_ptr<interfaces::Init> init{std::make_unique<TestInit>()}; |
| 125 | std::unique_ptr<ipc::Protocol> protocol{ipc::capnp::MakeCapnpProtocol()}; |
| 126 | std::promise<void> promise; |
| 127 | std::thread thread([&]() { |
| 128 | protocol->serve(fds[0], "test-serve", *init, [&] { promise.set_value(); }); |
| 129 | }); |
| 130 | promise.get_future().wait(); |
| 131 | std::unique_ptr<interfaces::Init> remote_init{protocol->connect(fds[1], "test-connect")}; |
| 132 | std::unique_ptr<interfaces::Echo> remote_echo{remote_init->makeEcho()}; |
| 133 | BOOST_CHECK_EQUAL(remote_echo->echo("echo test"), "echo test"); |
| 134 | remote_echo.reset(); |
| 135 | remote_init.reset(); |
| 136 | thread.join(); |
| 137 | } |
| 138 | |
| 139 | //! Test ipc::Process bind() and connect() methods connecting over a unix socket. |
| 140 | void IpcSocketTest(const fs::path& datadir) |
no test coverage detected