Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / unittests / Host / ConnectionFileDescriptorTest.cpp
blob250ed6fe8fd37275be6cc63651192af035575f10
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-exception
6 //
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 {
18 public:
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(), "/"}),
30 *URI::Parse(uri));
34 TEST_F(ConnectionFileDescriptorTest, TCPGetURIv4) {
35 if (!HostSupportsIPv4())
36 return;
37 TestGetURI("127.0.0.1");
40 TEST_F(ConnectionFileDescriptorTest, TCPGetURIv6) {
41 if (!HostSupportsIPv6())
42 return;
43 TestGetURI("::1");