AMDGPU: Fix verifier assert with out of bounds subregister indexes (#119799)
[llvm-project.git] / lldb / unittests / Process / gdb-remote / GDBRemoteCommunicationServerTest.cpp
blobba9ca6ea73e3bec6f6244b4c4968bbd9d0ca6bd8
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"
15 #include "lldb/lldb-enumerations.h"
17 namespace lldb_private {
18 namespace process_gdb_remote {
20 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorNumber) {
21 MockServerWithMockConnection server;
22 server.SendErrorResponse(0x42);
24 EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$E42#ab"));
27 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_Status) {
28 MockServerWithMockConnection server;
29 Status status(0x42, lldb::eErrorTypePOSIX, "Test error message");
30 server.SendErrorResponse(status);
32 EXPECT_THAT(
33 server.GetPackets(),
34 testing::ElementsAre("$E42;54657374206572726f72206d657373616765#ad"));
37 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_UnimplementedError) {
38 MockServerWithMockConnection server;
40 auto error = llvm::make_error<UnimplementedError>();
41 server.SendErrorResponse(std::move(error));
43 EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$#00"));
46 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_StringError) {
47 MockServerWithMockConnection server;
49 auto error = llvm::createStringError(llvm::inconvertibleErrorCode(),
50 "String error test");
51 server.SendErrorResponse(std::move(error));
53 EXPECT_THAT(
54 server.GetPackets(),
55 testing::ElementsAre("$Eff;537472696e67206572726f722074657374#b0"));
58 TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorList) {
59 MockServerWithMockConnection server;
61 auto error = llvm::joinErrors(llvm::make_error<UnimplementedError>(),
62 llvm::make_error<UnimplementedError>());
64 server.SendErrorResponse(std::move(error));
65 // Make sure only one packet is sent even when there are multiple errors.
66 EXPECT_EQ(server.GetPackets().size(), 1UL);
69 } // namespace process_gdb_remote
70 } // namespace lldb_private