aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.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/GDBRemoteCommunicationClientTest.cpp
parentf63ad39e7da18dd3502036b9b4f1203750bd9ea9 (diff)
downloadllvm-93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1.zip
llvm-93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1.tar.gz
llvm-93df2fbeabaf5f706ff01aafc7b03a811bf8c5a1.tar.bz2
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/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r--lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp109
1 files changed, 11 insertions, 98 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 8f6f9f0..cd2583b 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/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;