================ @@ -0,0 +1,195 @@ +//===-- ProtocolServerMCPTest.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 "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h" +#include "Plugins/Protocol/MCP/ProtocolServerMCP.h" +#include "TestingSupport/Host/SocketTestUtilities.h" +#include "TestingSupport/SubsystemRAII.h" +#include "lldb/Core/ProtocolServer.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Host/Socket.h" +#include "llvm/Testing/Support/Error.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::mcp::protocol; + +namespace { +class TestProtocolServerMCP : public lldb_private::mcp::ProtocolServerMCP { +public: + using ProtocolServerMCP::AddTool; + using ProtocolServerMCP::GetSocket; + using ProtocolServerMCP::ProtocolServerMCP; +}; + +class TestJSONTransport : public lldb_private::JSONRPCTransport { +public: + using JSONRPCTransport::JSONRPCTransport; + using JSONRPCTransport::ReadImpl; + using JSONRPCTransport::WriteImpl; +}; + +class TestTool : public mcp::Tool { +public: + using mcp::Tool::Tool; + + virtual mcp::protocol::TextResult + Call(const llvm::json::Value &args) override { + std::string argument; + if (const json::Object *args_obj = args.getAsObject()) { + if (const json::Value *s = args_obj->get("arguments")) { + argument = s->getAsString().value_or(""); + } + } + + mcp::protocol::TextResult text_result; + text_result.content.emplace_back(mcp::protocol::TextContent{{argument}}); + return text_result; + } +}; + +class ProtocolServerMCPTest : public ::testing::Test { +public: + SubsystemRAII<FileSystem, HostInfo, PlatformRemoteMacOSX, Socket> subsystems; + DebuggerSP m_debugger_sp; + + lldb::IOObjectSP m_io_sp; + std::unique_ptr<TestJSONTransport> m_transport_up; + std::unique_ptr<TestProtocolServerMCP> m_server_up; + + static constexpr llvm::StringLiteral k_ip = "127.0.0.1"; ---------------- labath wrote:
can you make this "localhost"? We actually have servers with no IPv4 stack o_O https://github.com/llvm/llvm-project/pull/143628 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits