brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 171481a Raw
45 lines · cpp
1//===-- ConnectionFileDescriptorTest.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 "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"14 15using namespace lldb_private;16 17class ConnectionFileDescriptorTest : public testing::Test {18public:19  SubsystemRAII<Socket> subsystems;20 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    uint16_t socket_a_remote_port = socket_a_up->GetRemotePortNumber();26    ConnectionFileDescriptor connection_file_descriptor(std::move(socket_a_up));27 28    std::string uri(connection_file_descriptor.GetURI());29    EXPECT_EQ((URI{"connect", ip, socket_a_remote_port, "/"}),30              *URI::Parse(uri));31  }32};33 34TEST_F(ConnectionFileDescriptorTest, TCPGetURIv4) {35  if (!HostSupportsIPv4())36    return;37  TestGetURI("127.0.0.1");38}39 40TEST_F(ConnectionFileDescriptorTest, TCPGetURIv6) {41  if (!HostSupportsIPv6())42    return;43  TestGetURI("::1");44}45