[AArch64,ELF] Restrict MOVZ/MOVK to non-PIC large code model (#70178)
[llvm-project.git] / lldb / unittests / Process / gdb-remote / GDBRemoteCommunicationServerTest.cpp
blob6ab37599ae36bbdc45a53c0dcdbabc8c41068f64
1 //===-- GDBRemoteCommunicationServerTest.cpp ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #include "gmock/gmock.h"
9 #include "gtest/gtest.h"
11 #include "GDBRemoteTestUtils.h"
12 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
13 #include "lldb/Utility/Connection.h"
14 #include "lldb/Utility/UnimplementedError.h"
16 namespace lldb_private {
17 namespace process_gdb_remote {
19 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorNumber) {
20 MockServerWithMockConnection server;
21 server.SendErrorResponse(0x42);
23 EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$E42#ab"));
26 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_Status) {
27 MockServerWithMockConnection server;
28 Status status;
30 status.SetError(0x42, lldb::eErrorTypeGeneric);
31 status.SetErrorString("Test error message");
32 server.SendErrorResponse(status);
34 EXPECT_THAT(
35 server.GetPackets(),
36 testing::ElementsAre("$E42;54657374206572726f72206d657373616765#ad"));
39 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_UnimplementedError) {
40 MockServerWithMockConnection server;
42 auto error = llvm::make_error<UnimplementedError>();
43 server.SendErrorResponse(std::move(error));
45 EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$#00"));
48 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_StringError) {
49 MockServerWithMockConnection server;
51 auto error = llvm::createStringError(llvm::inconvertibleErrorCode(),
52 "String error test");
53 server.SendErrorResponse(std::move(error));
55 EXPECT_THAT(
56 server.GetPackets(),
57 testing::ElementsAre("$Eff;537472696e67206572726f722074657374#b0"));
60 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorList) {
61 MockServerWithMockConnection server;
63 auto error = llvm::joinErrors(llvm::make_error<UnimplementedError>(),
64 llvm::make_error<UnimplementedError>());
66 server.SendErrorResponse(std::move(error));
67 // Make sure only one packet is sent even when there are multiple errors.
68 EXPECT_EQ(server.GetPackets().size(), 1UL);
71 } // namespace process_gdb_remote
72 } // namespace lldb_private