summaryrefslogtreecommitdiff
path: root/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp109
1 files changed, 11 insertions, 98 deletions
diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 8f6f9f0684a3..cd2583bb8f54 100644
--- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -11,14 +11,14 @@
#include "GDBRemoteTestUtils.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/TraceOptions.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/DataBuffer.h"
-
+#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Testing/Support/Error.h"
using namespace lldb_private::process_gdb_remote;
using namespace lldb_private;
@@ -58,15 +58,18 @@ std::string one_register_hex = "41424344";
} // end anonymous namespace
-class GDBRemoteCommunicationClientTest : public GDBRemoteTest {};
+class GDBRemoteCommunicationClientTest : public GDBRemoteTest {
+public:
+ void SetUp() override {
+ ASSERT_THAT_ERROR(Connect(client, server), llvm::Succeeded());
+ }
-TEST_F(GDBRemoteCommunicationClientTest, WriteRegister) {
+protected:
TestClient client;
MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
+};
+TEST_F(GDBRemoteCommunicationClientTest, WriteRegister) {
const lldb::tid_t tid = 0x47;
const uint32_t reg_num = 4;
std::future<bool> write_result = std::async(std::launch::async, [&] {
@@ -87,12 +90,6 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteRegister) {
}
TEST_F(GDBRemoteCommunicationClientTest, WriteRegisterNoSuffix) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::tid_t tid = 0x47;
const uint32_t reg_num = 4;
std::future<bool> write_result = std::async(std::launch::async, [&] {
@@ -113,12 +110,6 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteRegisterNoSuffix) {
}
TEST_F(GDBRemoteCommunicationClientTest, ReadRegister) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::tid_t tid = 0x47;
const uint32_t reg_num = 4;
std::future<bool> async_result = std::async(
@@ -145,12 +136,6 @@ TEST_F(GDBRemoteCommunicationClientTest, ReadRegister) {
}
TEST_F(GDBRemoteCommunicationClientTest, SaveRestoreRegistersNoSuffix) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::tid_t tid = 0x47;
uint32_t save_id;
std::future<bool> async_result = std::async(std::launch::async, [&] {
@@ -170,12 +155,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SaveRestoreRegistersNoSuffix) {
}
TEST_F(GDBRemoteCommunicationClientTest, SyncThreadState) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::tid_t tid = 0x47;
std::future<bool> async_result = std::async(
std::launch::async, [&] { return client.SyncThreadState(tid); });
@@ -185,12 +164,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SyncThreadState) {
}
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
llvm::Triple triple("i386-pc-linux");
FileSpec file_specs[] = {
@@ -225,12 +198,6 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
}
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
llvm::Triple triple("i386-pc-linux");
FileSpec file_spec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix);
@@ -267,13 +234,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) {
}
TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
- std::thread server_thread([&server] {
+ std::thread server_thread([this] {
for (;;) {
StringExtractorGDBRemote request;
PacketResult result = server.GetPacket(request);
@@ -312,12 +273,6 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
std::future<Status> result = std::async(std::launch::async, [&] {
return client.SendSignalsToIgnore({2, 3, 5, 7, 0xB, 0xD, 0x11});
});
@@ -334,12 +289,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) {
}
TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::addr_t addr = 0xa000;
MemoryRegionInfo region_info;
std::future<Status> result = std::async(std::launch::async, [&] {
@@ -355,12 +304,6 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
}
TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
const lldb::addr_t addr = 0x4000;
MemoryRegionInfo region_info;
std::future<Status> result = std::async(std::launch::async, [&] {
@@ -372,12 +315,6 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendStartTracePacket) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
TraceOptions options;
Status error;
@@ -417,12 +354,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SendStartTracePacket) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendStopTracePacket) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
lldb::tid_t thread_id = 0x23;
lldb::user_id_t trace_id = 3;
@@ -444,12 +375,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SendStopTracePacket) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendGetDataPacket) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
lldb::tid_t thread_id = 0x23;
lldb::user_id_t trace_id = 3;
@@ -482,12 +407,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SendGetDataPacket) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendGetMetaDataPacket) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
lldb::tid_t thread_id = 0x23;
lldb::user_id_t trace_id = 3;
@@ -520,12 +439,6 @@ TEST_F(GDBRemoteCommunicationClientTest, SendGetMetaDataPacket) {
}
TEST_F(GDBRemoteCommunicationClientTest, SendGetTraceConfigPacket) {
- TestClient client;
- MockServer server;
- Connect(client, server);
- if (HasFailure())
- return;
-
lldb::tid_t thread_id = 0x23;
lldb::user_id_t trace_id = 3;
TraceOptions options;