Files
clang-p2996/lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.h
Pavel Labath 93df2fbeab 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
2017-06-22 15:54:21 +00:00

53 lines
1.6 KiB
C++

//===-- GDBRemoteTestUtils.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_unittests_Process_gdb_remote_GDBRemoteTestUtils_h
#define lldb_unittests_Process_gdb_remote_GDBRemoteTestUtils_h
#include "gtest/gtest.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
namespace lldb_private {
namespace process_gdb_remote {
class GDBRemoteTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
protected:
llvm::Error Connect(GDBRemoteCommunication &client,
GDBRemoteCommunication &server);
};
struct MockServer : public GDBRemoteCommunicationServer {
MockServer()
: GDBRemoteCommunicationServer("mock-server", "mock-server.listener") {
m_send_acks = false;
}
PacketResult SendPacket(llvm::StringRef payload) {
return GDBRemoteCommunicationServer::SendPacketNoLock(payload);
}
PacketResult GetPacket(StringExtractorGDBRemote &response) {
const bool sync_on_timeout = false;
return WaitForPacketNoLock(response, std::chrono::seconds(1),
sync_on_timeout);
}
using GDBRemoteCommunicationServer::SendOKResponse;
using GDBRemoteCommunicationServer::SendUnimplementedResponse;
};
} // namespace process_gdb_remote
} // namespace lldb_private
#endif // lldb_unittests_Process_gdb_remote_GDBRemoteTestUtils_h