summaryrefslogtreecommitdiff
path: root/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-26 20:33:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-26 20:33:56 +0000
commitfdea456ad833fbab0d3a296a58250950f11a498c (patch)
tree3db481072633e348326ee97c01d69518ed66b145 /unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
parent4befb1f96d641a958548654b2c3b674f0ce8404c (diff)
Diffstat (limited to 'unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp')
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp31
1 files changed, 17 insertions, 14 deletions
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<Status> accept_error = std::async(
+ std::future<Status> 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<ConnectionFileDescriptor> conn_ap(
+ std::unique_ptr<ConnectionFileDescriptor> 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<llvm::StringError>("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