diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /unittests/Process/gdb-remote | |
parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) |
Notes
Diffstat (limited to 'unittests/Process/gdb-remote')
5 files changed, 15 insertions, 45 deletions
diff --git a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp index 8ab0afdb9bea..187f1b2db9a3 100644 --- a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -48,7 +48,8 @@ struct TestClient : public GDBRemoteClientBase { class GDBRemoteClientBaseTest : public GDBRemoteTest { public: void SetUp() override { - ASSERT_THAT_ERROR(Connect(client, server), llvm::Succeeded()); + ASSERT_THAT_ERROR(GDBRemoteCommunication::ConnectLocally(client, server), + llvm::Succeeded()); ASSERT_EQ(TestClient::eBroadcastBitRunPacketSent, listener_sp->StartListeningForEvents( &client, TestClient::eBroadcastBitRunPacketSent)); diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 41ca091c8f10..bf31f958b969 100644 --- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -63,7 +63,8 @@ std::string one_register_hex = "41424344"; class GDBRemoteCommunicationClientTest : public GDBRemoteTest { public: void SetUp() override { - ASSERT_THAT_ERROR(Connect(client, server), llvm::Succeeded()); + ASSERT_THAT_ERROR(GDBRemoteCommunication::ConnectLocally(client, server), + llvm::Succeeded()); } protected: @@ -169,14 +170,14 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) { llvm::Triple triple("i386-pc-linux"); FileSpec file_specs[] = { - FileSpec("/foo/bar.so", false, FileSpec::Style::posix), - FileSpec("/foo/baz.so", false, FileSpec::Style::posix), + FileSpec("/foo/bar.so", FileSpec::Style::posix), + FileSpec("/foo/baz.so", FileSpec::Style::posix), // This is a bit dodgy but we currently depend on GetModulesInfo not // performing denormalization. It can go away once the users // (DynamicLoaderPOSIXDYLD, at least) correctly set the path syntax for // the FileSpecs they create. - FileSpec("/foo/baw.so", false, FileSpec::Style::windows), + FileSpec("/foo/baw.so", FileSpec::Style::windows), }; std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result = std::async(std::launch::async, @@ -203,7 +204,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) { TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) { llvm::Triple triple("i386-pc-linux"); - FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix); + FileSpec file_spec("/foo/bar.so", FileSpec::Style::posix); std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result = std::async(std::launch::async, [&] { return client.GetModulesInfo(file_spec, triple); }); @@ -227,7 +228,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) { TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) { llvm::Triple triple("i386-pc-linux"); - FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix); + FileSpec file_spec("/foo/bar.so", FileSpec::Style::posix); const char *invalid_responses[] = { // no UUID diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp index 5ae8e700757c..fd3e93797d26 100644 --- a/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp @@ -30,7 +30,8 @@ public: class GDBRemoteCommunicationTest : public GDBRemoteTest { public: void SetUp() override { - ASSERT_THAT_ERROR(Connect(client, server), llvm::Succeeded()); + ASSERT_THAT_ERROR(GDBRemoteCommunication::ConnectLocally(client, server), + llvm::Succeeded()); } protected: diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp index 2acf72744d20..9a9d8a3be471 100644 --- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp @@ -9,10 +9,10 @@ #include "GDBRemoteTestUtils.h" -#include "lldb/Host/common/TCPSocket.h" -#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" - -#include <future> +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include <WinSock2.h> +#endif namespace lldb_private { namespace process_gdb_remote { @@ -30,34 +30,5 @@ void GDBRemoteTest::TearDownTestCase() { #endif } -llvm::Error GDBRemoteTest::Connect(GDBRemoteCommunication &client, - GDBRemoteCommunication &server) { - bool child_processes_inherit = false; - TCPSocket listen_socket(true, child_processes_inherit); - if (llvm::Error error = listen_socket.Listen("127.0.0.1:0", 5).ToError()) - return error; - - Socket *accept_socket; - std::future<Status> accept_status = std::async( - std::launch::async, [&] { return listen_socket.Accept(accept_socket); }); - - llvm::SmallString<32> remote_addr; - llvm::raw_svector_ostream(remote_addr) - << "connect://localhost:" << listen_socket.GetLocalPortNumber(); - - std::unique_ptr<ConnectionFileDescriptor> conn_up( - new ConnectionFileDescriptor()); - 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; - - server.SetConnection(new ConnectionFileDescriptor(accept_socket)); - return llvm::Error::success(); -} - } // namespace process_gdb_remote } // namespace lldb_private diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.h b/unittests/Process/gdb-remote/GDBRemoteTestUtils.h index cc17422049bc..90f95932c642 100644 --- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.h +++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.h @@ -20,10 +20,6 @@ class GDBRemoteTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - -protected: - llvm::Error Connect(GDBRemoteCommunication &client, - GDBRemoteCommunication &server); }; struct MockServer : public GDBRemoteCommunicationServer { |