summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-06-22 15:54:21 +0000
committerPavel Labath <labath@google.com>2017-06-22 15:54:21 +0000
commit93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1 (patch)
treea273d25bdb87c864a31ccc69ab35a84906ac9a70 /lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
parentf63ad39e7da18dd3502036b9b4f1203750bd9ea9 (diff)
downloadbcm5719-llvm-93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1.tar.gz
bcm5719-llvm-93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1.zip
Simplify the gdb-remote unit tests
Instead of every test creating a client-server combo, do that in the SetUp method of the test fixture. This also means that we can rely on gtest to not run the test if the SetUp method fails and delete the if(HasFailure) calls. llvm-svn: 306013
Diffstat (limited to 'lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp')
-rw-r--r--lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
index 4a86b91c048..2acf72744d2 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ b/lldb/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
OpenPOWER on IntegriCloud