CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
121 lines
3.8 KiB
C++
121 lines
3.8 KiB
C++
//===-- TestBase.cpp ------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "DAP.h"
|
|
#include "DAPLog.h"
|
|
#include "Handler/RequestHandler.h"
|
|
#include "Handler/ResponseHandler.h"
|
|
#include "Protocol/ProtocolBase.h"
|
|
#include "TestingSupport/Host/JSONTransportTestUtilities.h"
|
|
#include "TestingSupport/SubsystemRAII.h"
|
|
#include "Transport.h"
|
|
#include "lldb/Host/FileSystem.h"
|
|
#include "lldb/Host/HostInfo.h"
|
|
#include "lldb/Host/MainLoop.h"
|
|
#include "lldb/Host/MainLoopBase.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/FileSystem.h"
|
|
#include "llvm/Support/JSON.h"
|
|
#include "gmock/gmock.h"
|
|
#include "gtest/gtest.h"
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
/// Helpers for gtest printing.
|
|
namespace lldb_dap::protocol {
|
|
|
|
inline void PrintTo(const Request &req, std::ostream *os) {
|
|
*os << llvm::formatv("{0}", toJSON(req)).str();
|
|
}
|
|
|
|
inline void PrintTo(const Response &resp, std::ostream *os) {
|
|
*os << llvm::formatv("{0}", toJSON(resp)).str();
|
|
}
|
|
|
|
inline void PrintTo(const Event &evt, std::ostream *os) {
|
|
*os << llvm::formatv("{0}", toJSON(evt)).str();
|
|
}
|
|
|
|
inline void PrintTo(const Message &message, std::ostream *os) {
|
|
return std::visit([os](auto &&message) { return PrintTo(message, os); },
|
|
message);
|
|
}
|
|
|
|
} // namespace lldb_dap::protocol
|
|
|
|
namespace lldb_dap_tests {
|
|
|
|
using TestDAPTransport = TestTransport<lldb_dap::ProtocolDescriptor>;
|
|
|
|
/// A base class for tests that need transport configured for communicating DAP
|
|
/// messages.
|
|
class TransportBase : public testing::Test {
|
|
protected:
|
|
lldb_private::SubsystemRAII<lldb_private::FileSystem, lldb_private::HostInfo>
|
|
subsystems;
|
|
lldb_private::MainLoop loop;
|
|
|
|
std::unique_ptr<lldb_dap::Log> log;
|
|
lldb_dap::Log::Mutex log_mutex;
|
|
|
|
std::unique_ptr<TestDAPTransport> to_client;
|
|
MockMessageHandler<lldb_dap::ProtocolDescriptor> client;
|
|
|
|
std::unique_ptr<TestDAPTransport> to_server;
|
|
std::unique_ptr<lldb_dap::DAP> dap;
|
|
|
|
void SetUp() override;
|
|
|
|
void Run();
|
|
};
|
|
|
|
/// A matcher for a DAP event.
|
|
template <typename EventMatcher, typename BodyMatcher>
|
|
inline testing::Matcher<const lldb_dap::protocol::Event &>
|
|
IsEvent(const EventMatcher &event_matcher, const BodyMatcher &body_matcher) {
|
|
return testing::AllOf(
|
|
testing::Field(&lldb_dap::protocol::Event::event, event_matcher),
|
|
testing::Field(&lldb_dap::protocol::Event::body, body_matcher));
|
|
}
|
|
|
|
template <typename EventMatcher>
|
|
inline testing::Matcher<const lldb_dap::protocol::Event &>
|
|
IsEvent(const EventMatcher &event_matcher) {
|
|
return testing::AllOf(
|
|
testing::Field(&lldb_dap::protocol::Event::event, event_matcher),
|
|
testing::Field(&lldb_dap::protocol::Event::body, std::nullopt));
|
|
}
|
|
|
|
/// Matches an "output" event.
|
|
inline auto Output(llvm::StringRef o, llvm::StringRef cat = "console") {
|
|
return IsEvent("output",
|
|
testing::Optional(llvm::json::Value(
|
|
llvm::json::Object{{"category", cat}, {"output", o}})));
|
|
}
|
|
|
|
/// A base class for tests that interact with a `lldb_dap::DAP` instance.
|
|
class DAPTestBase : public TransportBase {
|
|
protected:
|
|
std::optional<llvm::sys::fs::TempFile> core;
|
|
std::optional<llvm::sys::fs::TempFile> binary;
|
|
|
|
static constexpr llvm::StringLiteral k_linux_binary = "linux-x86_64.out.yaml";
|
|
static constexpr llvm::StringLiteral k_linux_core = "linux-x86_64.core.yaml";
|
|
|
|
static void SetUpTestSuite();
|
|
static void TearDownTestSuite();
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
bool GetDebuggerSupportsTarget(llvm::StringRef platform);
|
|
void CreateDebugger();
|
|
void LoadCore();
|
|
};
|
|
|
|
} // namespace lldb_dap_tests
|