brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 212c569 Raw
61 lines · cpp
1//===-- DisconnectTest.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-exception6//7//===----------------------------------------------------------------------===//8 9#include "DAP.h"10#include "Handler/RequestHandler.h"11#include "Protocol/ProtocolBase.h"12#include "TestBase.h"13#include "lldb/API/SBDefines.h"14#include "lldb/lldb-enumerations.h"15#include "llvm/Testing/Support/Error.h"16#include "gmock/gmock.h"17#include "gtest/gtest.h"18#include <memory>19#include <optional>20 21using namespace llvm;22using namespace lldb;23using namespace lldb_dap;24using namespace lldb_dap_tests;25using namespace lldb_dap::protocol;26using testing::_;27 28class DisconnectRequestHandlerTest : public DAPTestBase {};29 30TEST_F(DisconnectRequestHandlerTest, DisconnectTriggersTerminated) {31  DisconnectRequestHandler handler(*dap);32  ASSERT_THAT_ERROR(handler.Run(std::nullopt), Succeeded());33  EXPECT_CALL(client, Received(IsEvent("terminated", _)));34  Run();35}36 37// Is flaky on Linux, see https://github.com/llvm/llvm-project/issues/154763.38#ifndef __linux__39TEST_F(DisconnectRequestHandlerTest, DisconnectTriggersTerminateCommands) {40  CreateDebugger();41 42  if (!GetDebuggerSupportsTarget("X86"))43    GTEST_SKIP() << "Unsupported platform";44 45  LoadCore();46 47  DisconnectRequestHandler handler(*dap);48 49  dap->configuration.terminateCommands = {"?script print(1)",50                                          "script print(2)"};51  EXPECT_EQ(dap->target.GetProcess().GetState(), lldb::eStateStopped);52  ASSERT_THAT_ERROR(handler.Run(std::nullopt), Succeeded());53  EXPECT_CALL(client, Received(Output("1\n")));54  EXPECT_CALL(client, Received(Output("2\n"))).Times(2);55  EXPECT_CALL(client, Received(Output("(lldb) script print(2)\n")));56  EXPECT_CALL(client, Received(Output("Running terminateCommands:\n")));57  EXPECT_CALL(client, Received(IsEvent("terminated", _)));58  Run();59}60#endif61