
This patch fixes a crash when using process launch -t to launch the inferior from a TTY. The issue is that on Darwin, Host.mm is calling ConnectionFileDescriptor::Connect without a socket_id_callback_type. The overload passes nullptr as the function ref, which gets called unconditionally as the socket_id_callback. One potential way to fix this is to change all the lambdas to include a null check, but instead I went with an empty lambda. Differential revision: https://reviews.llvm.org/D124535
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
//===-- ConnectionFileDescriptorTest.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 "SocketTestUtilities.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "TestingSupport/SubsystemRAII.h"
|
|
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
|
|
#include "lldb/Utility/UriParser.h"
|
|
|
|
using namespace lldb_private;
|
|
|
|
class ConnectionFileDescriptorTest : public testing::Test {
|
|
public:
|
|
SubsystemRAII<Socket> subsystems;
|
|
|
|
void TestGetURI(std::string ip) {
|
|
std::unique_ptr<TCPSocket> socket_a_up;
|
|
std::unique_ptr<TCPSocket> socket_b_up;
|
|
CreateTCPConnectedSockets(ip, &socket_a_up, &socket_b_up);
|
|
auto *socket = socket_a_up.release();
|
|
ConnectionFileDescriptor connection_file_descriptor(socket);
|
|
|
|
std::string uri(connection_file_descriptor.GetURI());
|
|
EXPECT_EQ((URI{"connect", ip, socket->GetRemotePortNumber(), "/"}),
|
|
URI::Parse(uri).getValue());
|
|
}
|
|
|
|
void TestConnect(std::string ip, std::string path) {
|
|
std::unique_ptr<TCPSocket> socket_a_up;
|
|
std::unique_ptr<TCPSocket> socket_b_up;
|
|
CreateTCPConnectedSockets(ip, &socket_a_up, &socket_b_up);
|
|
auto *socket = socket_a_up.release();
|
|
ConnectionFileDescriptor connection_file_descriptor(socket);
|
|
connection_file_descriptor.Connect(path, nullptr);
|
|
}
|
|
};
|
|
|
|
TEST_F(ConnectionFileDescriptorTest, TCPGetURIv4) {
|
|
if (!HostSupportsIPv4())
|
|
return;
|
|
TestGetURI("127.0.0.1");
|
|
}
|
|
|
|
TEST_F(ConnectionFileDescriptorTest, TCPGetURIv6) {
|
|
if (!HostSupportsIPv6())
|
|
return;
|
|
TestGetURI("::1");
|
|
}
|
|
|
|
TEST_F(ConnectionFileDescriptorTest, Connectv4) {
|
|
if (!HostSupportsIPv4())
|
|
return;
|
|
TestConnect("127.0.0.1", "accept://127.0.0.1");
|
|
}
|
|
|
|
TEST_F(ConnectionFileDescriptorTest, Connectv6) {
|
|
if (!HostSupportsIPv6())
|
|
return;
|
|
TestConnect("::1", "accept://::1");
|
|
}
|