aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/common/ut/network_ut.cpp
diff options
context:
space:
mode:
authorbulatman <bulatman@yandex-team.ru>2022-02-10 16:45:50 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:50 +0300
commit2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /library/cpp/testing/common/ut/network_ut.cpp
parent6560e4993b14d193f8c879e33a3de5e5eba6e21d (diff)
downloadydb-2f6ca198245aeffd5e2d82b65927c2465b68b4f5.tar.gz
Restoring authorship annotation for <bulatman@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/common/ut/network_ut.cpp')
-rw-r--r--library/cpp/testing/common/ut/network_ut.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/library/cpp/testing/common/ut/network_ut.cpp b/library/cpp/testing/common/ut/network_ut.cpp
index 11ba48fd5d..6a40775fd9 100644
--- a/library/cpp/testing/common/ut/network_ut.cpp
+++ b/library/cpp/testing/common/ut/network_ut.cpp
@@ -1,54 +1,54 @@
-#include <library/cpp/testing/common/network.h>
-#include <library/cpp/testing/common/scope.h>
-
-#include <util/generic/hash_set.h>
-
-#include <util/folder/dirut.h>
-#include <util/folder/path.h>
-#include <util/folder/tempdir.h>
-#include <util/network/sock.h>
-#include <util/system/fs.h>
-
-#include <library/cpp/testing/gtest/gtest.h>
-
-static TTempDir TmpDir;
-
-TEST(NetworkTest, FreePort) {
- NTesting::TScopedEnvironment envGuard("PORT_SYNC_PATH", TmpDir.Name());
-
- TVector<NTesting::TPortHolder> ports(Reserve(100));
-
- for (size_t i = 0; i < 100; ++i) {
- ports.push_back(NTesting::GetFreePort());
- }
-
- THashSet<ui16> uniqPorts;
- for (auto& port : ports) {
- const TString guardPath = TmpDir.Path() / ToString(static_cast<ui16>(port));
- EXPECT_TRUE(NFs::Exists(guardPath));
- EXPECT_TRUE(uniqPorts.emplace(port).second);
-
- TInetStreamSocket sock;
- TSockAddrInet addr(TIpHost{INADDR_ANY}, port);
- ASSERT_EQ(0, SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1));
- EXPECT_EQ(0, sock.Bind(&addr));
- }
- ports.clear();
- for (ui16 port : uniqPorts) {
- const TString guardPath = TmpDir.Path() / ToString(port);
- EXPECT_FALSE(NFs::Exists(guardPath));
- }
-}
-
-
-TEST(FreePortTest, FreePortsRange) {
- NTesting::TScopedEnvironment envGuard("PORT_SYNC_PATH", TmpDir.Name());
-
- for (ui16 i = 2; i < 10; ++i) {
- TVector<NTesting::TPortHolder> ports = NTesting::NLegacy::GetFreePortsRange(i);
- ASSERT_EQ(i, ports.size());
- for (ui16 j = 1; j < i; ++j) {
- EXPECT_EQ(static_cast<ui16>(ports[j]), static_cast<ui16>(ports[0]) + j);
- }
- }
-}
+#include <library/cpp/testing/common/network.h>
+#include <library/cpp/testing/common/scope.h>
+
+#include <util/generic/hash_set.h>
+
+#include <util/folder/dirut.h>
+#include <util/folder/path.h>
+#include <util/folder/tempdir.h>
+#include <util/network/sock.h>
+#include <util/system/fs.h>
+
+#include <library/cpp/testing/gtest/gtest.h>
+
+static TTempDir TmpDir;
+
+TEST(NetworkTest, FreePort) {
+ NTesting::TScopedEnvironment envGuard("PORT_SYNC_PATH", TmpDir.Name());
+
+ TVector<NTesting::TPortHolder> ports(Reserve(100));
+
+ for (size_t i = 0; i < 100; ++i) {
+ ports.push_back(NTesting::GetFreePort());
+ }
+
+ THashSet<ui16> uniqPorts;
+ for (auto& port : ports) {
+ const TString guardPath = TmpDir.Path() / ToString(static_cast<ui16>(port));
+ EXPECT_TRUE(NFs::Exists(guardPath));
+ EXPECT_TRUE(uniqPorts.emplace(port).second);
+
+ TInetStreamSocket sock;
+ TSockAddrInet addr(TIpHost{INADDR_ANY}, port);
+ ASSERT_EQ(0, SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1));
+ EXPECT_EQ(0, sock.Bind(&addr));
+ }
+ ports.clear();
+ for (ui16 port : uniqPorts) {
+ const TString guardPath = TmpDir.Path() / ToString(port);
+ EXPECT_FALSE(NFs::Exists(guardPath));
+ }
+}
+
+
+TEST(FreePortTest, FreePortsRange) {
+ NTesting::TScopedEnvironment envGuard("PORT_SYNC_PATH", TmpDir.Name());
+
+ for (ui16 i = 2; i < 10; ++i) {
+ TVector<NTesting::TPortHolder> ports = NTesting::NLegacy::GetFreePortsRange(i);
+ ASSERT_EQ(i, ports.size());
+ for (ui16 j = 1; j < i; ++j) {
+ EXPECT_EQ(static_cast<ui16>(ports[j]), static_cast<ui16>(ports[0]) + j);
+ }
+ }
+}