MCPcopy Create free account
hub / github.com/catboost/catboost / TEST_F

Function TEST_F

library/cpp/testing/common/ut/network_ut.cpp:34–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32class FreePortTest: public NetworkTestBase {};
33
34TEST_F(NetworkTest, FreePort) {
35 NTesting::TScopedEnvironment envGuard("PORT_SYNC_PATH", TmpDir->Name());
36 NTesting::InitPortManagerFromEnv();
37 TVector<NTesting::TPortHolder> ports(Reserve(100));
38
39 for (size_t i = 0; i < 100; ++i) {
40 ports.push_back(NTesting::GetFreePort());
41 }
42
43 THashSet<ui16> uniqPorts;
44 for (auto& port : ports) {
45 const TString guardPath = TmpDir->Path() / ToString(static_cast<ui16>(port));
46 EXPECT_TRUE(NFs::Exists(guardPath));
47 EXPECT_TRUE(uniqPorts.emplace(port).second);
48
49 TInetStreamSocket sock;
50 TSockAddrInet addr(TIpHost{INADDR_ANY}, port);
51 ASSERT_EQ(0, SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1));
52 EXPECT_EQ(0, sock.Bind(&addr));
53 }
54 ports.clear();
55 for (ui16 port : uniqPorts) {
56 const TString guardPath = TmpDir->Path() / ToString(port);
57 EXPECT_FALSE(NFs::Exists(guardPath));
58 }
59}
60
61TEST_F(NetworkTest, FreePortWithinRanges) {
62 NTesting::TScopedEnvironment envGuard{{

Callers

nothing calls this directly

Calls 15

InitPortManagerFromEnvFunction · 0.85
ReserveFunction · 0.85
GetFreePortFunction · 0.85
SetSockOptFunction · 0.85
GetPortFunction · 0.85
GetFreePortsRangeFunction · 0.85
ToStringFunction · 0.50
ChmodFunction · 0.50
NameMethod · 0.45
push_backMethod · 0.45
emplaceMethod · 0.45
BindMethod · 0.45

Tested by

no test coverage detected