aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest/tests_data.cpp
diff options
context:
space:
mode:
authorAleksandr <ivansduck@gmail.com>2022-02-10 16:47:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:52 +0300
commitb05913d1c3c02a773578bceb7285084d2933ae86 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/testing/unittest/tests_data.cpp
parentea6c5b7f172becca389cacaff7d5f45f6adccbe6 (diff)
downloadydb-b05913d1c3c02a773578bceb7285084d2933ae86.tar.gz
Restoring authorship annotation for Aleksandr <ivansduck@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/unittest/tests_data.cpp')
-rw-r--r--library/cpp/testing/unittest/tests_data.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/testing/unittest/tests_data.cpp b/library/cpp/testing/unittest/tests_data.cpp
index d1edd84196..b51cbc4b87 100644
--- a/library/cpp/testing/unittest/tests_data.cpp
+++ b/library/cpp/testing/unittest/tests_data.cpp
@@ -6,52 +6,52 @@
#include <util/system/env.h>
#include <util/system/mutex.h>
-class TPortManager::TPortManagerImpl {
-public:
+class TPortManager::TPortManagerImpl {
+public:
TPortManagerImpl(bool reservePortsForCurrentTest)
: EnableReservePortsForCurrentTest(reservePortsForCurrentTest)
, DisableRandomPorts(!GetEnv("NO_RANDOM_PORTS").empty())
{
- }
-
- ui16 GetPort(ui16 port) {
+ }
+
+ ui16 GetPort(ui16 port) {
if (port && DisableRandomPorts) {
- return port;
- }
-
+ return port;
+ }
+
TAtomicSharedPtr<NTesting::IPort> holder(NTesting::GetFreePort().Release());
ReservePortForCurrentTest(holder);
-
+
TGuard<TMutex> g(Lock);
ReservedPorts.push_back(holder);
return holder->Get();
}
-
+
ui16 GetUdpPort(ui16 port) {
return GetPort(port);
}
-
+
ui16 GetTcpPort(ui16 port) {
return GetPort(port);
- }
-
+ }
+
ui16 GetTcpAndUdpPort(ui16 port) {
return GetPort(port);
}
- ui16 GetPortsRange(const ui16 startPort, const ui16 range) {
+ ui16 GetPortsRange(const ui16 startPort, const ui16 range) {
Y_UNUSED(startPort);
auto ports = NTesting::NLegacy::GetFreePortsRange(range);
ui16 first = ports[0];
- TGuard<TMutex> g(Lock);
+ TGuard<TMutex> g(Lock);
for (auto& port : ports) {
ReservedPorts.emplace_back(port.Release());
ReservePortForCurrentTest(ReservedPorts.back());
- }
+ }
return first;
- }
-
-private:
+ }
+
+private:
void ReservePortForCurrentTest(const TAtomicSharedPtr<NTesting::IPort>& portGuard) {
if (EnableReservePortsForCurrentTest) {
TTestBase* currentTest = NUnitTest::NPrivate::GetCurrentTest();
@@ -64,40 +64,40 @@ private:
}
private:
- TMutex Lock;
+ TMutex Lock;
TVector<TAtomicSharedPtr<NTesting::IPort>> ReservedPorts;
const bool EnableReservePortsForCurrentTest;
const bool DisableRandomPorts;
-};
-
+};
+
TPortManager::TPortManager(bool reservePortsForCurrentTest)
: Impl_(new TPortManagerImpl(reservePortsForCurrentTest))
-{
-}
-
-TPortManager::~TPortManager() {
-}
-
-ui16 TPortManager::GetPort(ui16 port) {
- return Impl_->GetTcpPort(port);
-}
+{
+}
+
+TPortManager::~TPortManager() {
+}
+
+ui16 TPortManager::GetPort(ui16 port) {
+ return Impl_->GetTcpPort(port);
+}
ui16 TPortManager::GetTcpPort(ui16 port) {
- return Impl_->GetTcpPort(port);
+ return Impl_->GetTcpPort(port);
}
ui16 TPortManager::GetUdpPort(ui16 port) {
- return Impl_->GetUdpPort(port);
+ return Impl_->GetUdpPort(port);
}
ui16 TPortManager::GetTcpAndUdpPort(ui16 port) {
- return Impl_->GetTcpAndUdpPort(port);
+ return Impl_->GetTcpAndUdpPort(port);
+}
+
+ui16 TPortManager::GetPortsRange(const ui16 startPort, const ui16 range) {
+ return Impl_->GetPortsRange(startPort, range);
}
-ui16 TPortManager::GetPortsRange(const ui16 startPort, const ui16 range) {
- return Impl_->GetPortsRange(startPort, range);
-}
-
ui16 GetRandomPort() {
TPortManager* pm = Singleton<TPortManager>(false);
return pm->GetPort();