From fdea456ad833fbab0d3a296a58250950f11a498c Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 26 Jun 2017 20:33:56 +0000 Subject: Vendor import of lldb trunk r306325: https://llvm.org/svn/llvm-project/lldb/trunk@306325 --- .../Process/gdb-remote/GDBRemoteTestUtils.cpp | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp') diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp index 4a86b91c0489..2acf72744d20 100644 --- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp @@ -30,30 +30,33 @@ void GDBRemoteTest::TearDownTestCase() { #endif } -void Connect(GDBRemoteCommunication &client, GDBRemoteCommunication &server) { +llvm::Error GDBRemoteTest::Connect(GDBRemoteCommunication &client, + GDBRemoteCommunication &server) { bool child_processes_inherit = false; - Status error; TCPSocket listen_socket(true, child_processes_inherit); - ASSERT_FALSE(error.Fail()); - error = listen_socket.Listen("127.0.0.1:0", 5); - ASSERT_FALSE(error.Fail()); + if (llvm::Error error = listen_socket.Listen("127.0.0.1:0", 5).ToError()) + return error; Socket *accept_socket; - std::future accept_error = std::async( + std::future accept_status = std::async( std::launch::async, [&] { return listen_socket.Accept(accept_socket); }); - char connect_remote_address[64]; - snprintf(connect_remote_address, sizeof(connect_remote_address), - "connect://localhost:%u", listen_socket.GetLocalPortNumber()); + llvm::SmallString<32> remote_addr; + llvm::raw_svector_ostream(remote_addr) + << "connect://localhost:" << listen_socket.GetLocalPortNumber(); - std::unique_ptr conn_ap( + std::unique_ptr conn_up( new ConnectionFileDescriptor()); - ASSERT_EQ(conn_ap->Connect(connect_remote_address, nullptr), - lldb::eConnectionStatusSuccess); + if (conn_up->Connect(remote_addr, nullptr) != lldb::eConnectionStatusSuccess) + return llvm::make_error("Unable to connect", + llvm::inconvertibleErrorCode()); + + client.SetConnection(conn_up.release()); + if (llvm::Error error = accept_status.get().ToError()) + return error; - client.SetConnection(conn_ap.release()); - ASSERT_TRUE(accept_error.get().Success()); server.SetConnection(new ConnectionFileDescriptor(accept_socket)); + return llvm::Error::success(); } } // namespace process_gdb_remote -- cgit v1.2.3