1 //===-- ConnectionFileDescriptorTest.cpp ----------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "TestingSupport/Host/SocketTestUtilities.h"
10 #include "gtest/gtest.h"
11 #include "TestingSupport/SubsystemRAII.h"
12 #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
13 #include "lldb/Utility/UriParser.h"
15 using namespace lldb_private
;
17 class ConnectionFileDescriptorTest
: public testing::Test
{
19 SubsystemRAII
<Socket
> subsystems
;
21 void TestGetURI(std::string ip
) {
22 std::unique_ptr
<TCPSocket
> socket_a_up
;
23 std::unique_ptr
<TCPSocket
> socket_b_up
;
24 CreateTCPConnectedSockets(ip
, &socket_a_up
, &socket_b_up
);
25 auto *socket
= socket_a_up
.release();
26 ConnectionFileDescriptor
connection_file_descriptor(socket
);
28 std::string
uri(connection_file_descriptor
.GetURI());
29 EXPECT_EQ((URI
{"connect", ip
, socket
->GetRemotePortNumber(), "/"}),
34 TEST_F(ConnectionFileDescriptorTest
, TCPGetURIv4
) {
35 if (!HostSupportsIPv4())
37 TestGetURI("127.0.0.1");
40 TEST_F(ConnectionFileDescriptorTest
, TCPGetURIv6
) {
41 if (!HostSupportsIPv6())