aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing
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
parent6560e4993b14d193f8c879e33a3de5e5eba6e21d (diff)
downloadydb-2f6ca198245aeffd5e2d82b65927c2465b68b4f5.tar.gz
Restoring authorship annotation for <bulatman@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing')
-rw-r--r--library/cpp/testing/README.md6
-rw-r--r--library/cpp/testing/benchmark/bench.cpp2
-rw-r--r--library/cpp/testing/benchmark/examples/ya.make2
-rw-r--r--library/cpp/testing/common/env.cpp36
-rw-r--r--library/cpp/testing/common/env.h44
-rw-r--r--library/cpp/testing/common/network.cpp406
-rw-r--r--library/cpp/testing/common/network.h100
-rw-r--r--library/cpp/testing/common/probe.cpp2
-rw-r--r--library/cpp/testing/common/probe.h264
-rw-r--r--library/cpp/testing/common/scope.cpp2
-rw-r--r--library/cpp/testing/common/scope.h78
-rw-r--r--library/cpp/testing/common/ut/env_ut.cpp156
-rw-r--r--library/cpp/testing/common/ut/network_ut.cpp108
-rw-r--r--library/cpp/testing/common/ut/scope_ut.cpp56
-rw-r--r--library/cpp/testing/common/ut/ya.make36
-rw-r--r--library/cpp/testing/common/ya.make36
-rw-r--r--library/cpp/testing/gmock_in_unittest/ya.make4
-rw-r--r--library/cpp/testing/gtest_extensions/assertions.h4
-rw-r--r--library/cpp/testing/gtest_extensions/gtest_extensions.h2
-rw-r--r--library/cpp/testing/gtest_extensions/matchers.h44
-rw-r--r--library/cpp/testing/gtest_extensions/pretty_printers.h4
-rw-r--r--library/cpp/testing/gtest_extensions/probe.cpp22
-rw-r--r--library/cpp/testing/gtest_extensions/probe.h94
-rw-r--r--library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp16
-rw-r--r--library/cpp/testing/gtest_extensions/ut/probe_ut.cpp108
-rw-r--r--library/cpp/testing/gtest_extensions/ut/ya.make2
-rw-r--r--library/cpp/testing/gtest_extensions/ya.make6
-rw-r--r--library/cpp/testing/hook/README.md50
-rw-r--r--library/cpp/testing/hook/hook.cpp90
-rw-r--r--library/cpp/testing/hook/hook.h256
-rw-r--r--library/cpp/testing/hook/ya.make26
-rw-r--r--library/cpp/testing/unittest/env.h4
-rw-r--r--library/cpp/testing/unittest/plugin.h2
-rw-r--r--library/cpp/testing/unittest/tests_data.cpp70
-rw-r--r--library/cpp/testing/unittest/tests_data.h6
-rw-r--r--library/cpp/testing/unittest/utmain.cpp24
-rw-r--r--library/cpp/testing/unittest/ya.make14
-rw-r--r--library/cpp/testing/ya.make10
38 files changed, 1096 insertions, 1096 deletions
diff --git a/library/cpp/testing/README.md b/library/cpp/testing/README.md
index 15740c3ec6..e8e0391be4 100644
--- a/library/cpp/testing/README.md
+++ b/library/cpp/testing/README.md
@@ -6,11 +6,11 @@
* `common` — независимые вспомогательные функции. Например функции для получения аркадийных путей.
* `gmock` — прокси-библиотека для подключения `contrib/resticted/googltest/googlemock` без нарушения PEERDIR policy.
* `gtest` — реализация модуля `GTEST` — средства для интеграции фреймворка _googletest_ в Аркадию.
-* `gtest_boost_extensions` — расширения gtest и gmock, улучшающие поддержку типов из boost.
+* `gtest_boost_extensions` — расширения gtest и gmock, улучшающие поддержку типов из boost.
* `gtest_extensions` — расширения gtest и gmock, улучшающие поддержку Аркадийных типов. Все расширения включены в модуле `GTEST` по-умолчаниiю.
* `gtest_main` — реализация `int main(argc, argv)` для модуля `GTEST` (вынесена в отдельную библиотеку, чтобы в перспективе была возможна реализация `GTEST_WITH_CUSTOM_ENTRY_POINT`).
-* `gtest_protobuf` — утилиты для работы с протобуфом в тестах.
-* `hook` — хуки для выполнения пользовательских функций в тестах и бенчмарках.
+* `gtest_protobuf` — утилиты для работы с протобуфом в тестах.
+* `hook` — хуки для выполнения пользовательских функций в тестах и бенчмарках.
* `mock_server` — реализация http-сервера для тестов.
* `unittest` — реализация модуля UNITTEST — основного средства для тестирования тестов на С++ в Аркадии.
* `unittest_main` — реализация `int main(argc, argv)` для модуля UNITTEST (она вынесена в отдельную библиотеку, чтобы оставить возможность для реализации `UNITTEST_WITH_CUSTOM_ENTRY_POINT` и `YT_UNITTEST`.
diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp
index 14598848ff..08d8708005 100644
--- a/library/cpp/testing/benchmark/bench.cpp
+++ b/library/cpp/testing/benchmark/bench.cpp
@@ -512,7 +512,7 @@ namespace {
.Help("run benchmarks in parallel");
opts.AddLongOption('f', "format")
- .AddLongName("benchmark_format")
+ .AddLongName("benchmark_format")
.StoreResult(&OutFormat)
.RequiredArgument("FORMAT")
.DefaultValue("console")
diff --git a/library/cpp/testing/benchmark/examples/ya.make b/library/cpp/testing/benchmark/examples/ya.make
index 14d2c0d11f..7e696e127a 100644
--- a/library/cpp/testing/benchmark/examples/ya.make
+++ b/library/cpp/testing/benchmark/examples/ya.make
@@ -3,7 +3,7 @@ OWNER(
yazevnul
)
-Y_BENCHMARK()
+Y_BENCHMARK()
SRCS(
main.cpp
diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp
index a6acf90e2c..fa3a47fe16 100644
--- a/library/cpp/testing/common/env.cpp
+++ b/library/cpp/testing/common/env.cpp
@@ -1,5 +1,5 @@
-#include "env.h"
-
+#include "env.h"
+
#include <build/scripts/c_templates/svnversion.h>
#include <util/folder/dirut.h>
@@ -32,14 +32,14 @@ TString BuildRoot() {
}
}
-TString ArcadiaFromCurrentLocation(TStringBuf where, TStringBuf path) {
- return (TFsPath(ArcadiaSourceRoot()) / TFsPath(where).Parent() / path).Fix();
-}
-
-TString BinaryPath(TStringBuf path) {
- return (TFsPath(BuildRoot()) / path).Fix();
-}
-
+TString ArcadiaFromCurrentLocation(TStringBuf where, TStringBuf path) {
+ return (TFsPath(ArcadiaSourceRoot()) / TFsPath(where).Parent() / path).Fix();
+}
+
+TString BinaryPath(TStringBuf path) {
+ return (TFsPath(BuildRoot()) / path).Fix();
+}
+
TString GetArcadiaTestsData() {
TString atdRoot = NPrivate::GetTestEnv().ArcadiaTestsDataDir;
if (atdRoot) {
@@ -47,21 +47,21 @@ TString GetArcadiaTestsData() {
}
TString path = NPrivate::GetCwd();
- const char pathsep = GetDirectorySeparator();
+ const char pathsep = GetDirectorySeparator();
while (!path.empty()) {
TString dataDir = path + "/arcadia_tests_data";
- if (IsDir(dataDir)) {
+ if (IsDir(dataDir)) {
return dataDir;
- }
+ }
- size_t pos = path.find_last_of(pathsep);
- if (pos == TString::npos) {
+ size_t pos = path.find_last_of(pathsep);
+ if (pos == TString::npos) {
pos = 0;
- }
+ }
path.erase(pos);
}
- return {};
+ return {};
}
TString GetWorkPath() {
@@ -143,7 +143,7 @@ void StopProcessCoreWatching(int pid) {
}
}
-bool FromYaTest() {
+bool FromYaTest() {
return NPrivate::GetTestEnv().IsRunningFromTest;
}
diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h
index 6846ba3016..7b89aa1bed 100644
--- a/library/cpp/testing/common/env.h
+++ b/library/cpp/testing/common/env.h
@@ -4,39 +4,39 @@
#include <util/folder/path.h>
#include <util/generic/string.h>
-#include <util/generic/strbuf.h>
-#include <util/system/src_location.h>
+#include <util/generic/strbuf.h>
+#include <util/system/src_location.h>
-// @brief return full path to arcadia root
-TString ArcadiaSourceRoot();
+// @brief return full path to arcadia root
+TString ArcadiaSourceRoot();
-// @brief return full path for file or folder specified by known source location `where` and `path` which is relative to parent folder of `where`
+// @brief return full path for file or folder specified by known source location `where` and `path` which is relative to parent folder of `where`
// for the instance: there is 2 files in folder test example_ut.cpp and example.data, so full path to test/example.data can be obtained
-// from example_ut.cpp as ArcadiaFromCurrentLocation(__SOURCE_FILE__, "example.data")
-TString ArcadiaFromCurrentLocation(TStringBuf where, TStringBuf path);
+// from example_ut.cpp as ArcadiaFromCurrentLocation(__SOURCE_FILE__, "example.data")
+TString ArcadiaFromCurrentLocation(TStringBuf where, TStringBuf path);
-// @brief return build folder path
-TString BuildRoot();
+// @brief return build folder path
+TString BuildRoot();
-// @brief return full path to built artefact, where path is relative from arcadia root
-TString BinaryPath(TStringBuf path);
+// @brief return full path to built artefact, where path is relative from arcadia root
+TString BinaryPath(TStringBuf path);
-// @brief return true if environment is testenv otherwise false
-bool FromYaTest();
+// @brief return true if environment is testenv otherwise false
+bool FromYaTest();
-// @brief returns TestsData dir (from env:ARCADIA_TESTS_DATA_DIR or path to existing folder `arcadia_tests_data` within parent folders)
-TString GetArcadiaTestsData();
+// @brief returns TestsData dir (from env:ARCADIA_TESTS_DATA_DIR or path to existing folder `arcadia_tests_data` within parent folders)
+TString GetArcadiaTestsData();
-// @brief return current working dir (from env:TEST_WORK_PATH or cwd)
-TString GetWorkPath();
+// @brief return current working dir (from env:TEST_WORK_PATH or cwd)
+TString GetWorkPath();
-// @brief return tests output path (workdir + testing_out_stuff)
-TFsPath GetOutputPath();
+// @brief return tests output path (workdir + testing_out_stuff)
+TFsPath GetOutputPath();
-// @brief return path from env:YA_TEST_RAM_DRIVE_PATH
+// @brief return path from env:YA_TEST_RAM_DRIVE_PATH
const TString& GetRamDrivePath();
-// @brief return path from env:YA_TEST_OUTPUT_RAM_DRIVE_PATH
+// @brief return path from env:YA_TEST_OUTPUT_RAM_DRIVE_PATH
const TString& GetOutputRamDrivePath();
// @brief return test parameter by name. If not exists, return an empty string
@@ -54,7 +54,7 @@ void WatchProcessCore(int pid, const TFsPath& binaryPath, const TFsPath& cwd = T
// @brief mark the process as successfully completed - a test machinery won't try to recover core dump file for the process
void StopProcessCoreWatching(int pid);
-#define SRC_(path) ArcadiaFromCurrentLocation(__SOURCE_FILE__, path)
+#define SRC_(path) ArcadiaFromCurrentLocation(__SOURCE_FILE__, path)
namespace NPrivate {
class TTestEnv {
diff --git a/library/cpp/testing/common/network.cpp b/library/cpp/testing/common/network.cpp
index b06670b8d0..230c50ee6d 100644
--- a/library/cpp/testing/common/network.cpp
+++ b/library/cpp/testing/common/network.cpp
@@ -1,208 +1,208 @@
-#include "network.h"
-
-#include <util/folder/dirut.h>
-#include <util/folder/path.h>
-#include <util/generic/singleton.h>
-#include <util/generic/utility.h>
-#include <util/generic/vector.h>
-#include <util/generic/ylimits.h>
-#include <util/network/address.h>
-#include <util/network/sock.h>
-#include <util/random/random.h>
-#include <util/stream/file.h>
-#include <util/string/split.h>
-#include <util/system/env.h>
-#include <util/system/error.h>
-#include <util/system/file_lock.h>
-#include <util/system/fs.h>
-
-#ifdef _darwin_
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#endif
-
-namespace {
-#define Y_VERIFY_SYSERROR(expr) \
- do { \
- if (!(expr)) { \
- Y_FAIL(#expr ", errno=%d", LastSystemError()); \
- } \
- } while (false)
-
- class TPortGuard : public NTesting::IPort {
- public:
- TPortGuard(ui16 port, THolder<TFileLock> lock)
- : Lock_(std::move(lock))
- , Port_(port)
- {
- }
-
+#include "network.h"
+
+#include <util/folder/dirut.h>
+#include <util/folder/path.h>
+#include <util/generic/singleton.h>
+#include <util/generic/utility.h>
+#include <util/generic/vector.h>
+#include <util/generic/ylimits.h>
+#include <util/network/address.h>
+#include <util/network/sock.h>
+#include <util/random/random.h>
+#include <util/stream/file.h>
+#include <util/string/split.h>
+#include <util/system/env.h>
+#include <util/system/error.h>
+#include <util/system/file_lock.h>
+#include <util/system/fs.h>
+
+#ifdef _darwin_
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
+namespace {
+#define Y_VERIFY_SYSERROR(expr) \
+ do { \
+ if (!(expr)) { \
+ Y_FAIL(#expr ", errno=%d", LastSystemError()); \
+ } \
+ } while (false)
+
+ class TPortGuard : public NTesting::IPort {
+ public:
+ TPortGuard(ui16 port, THolder<TFileLock> lock)
+ : Lock_(std::move(lock))
+ , Port_(port)
+ {
+ }
+
~TPortGuard() override {
- Y_VERIFY_SYSERROR(NFs::Remove(Lock_->GetName()));
- }
-
- ui16 Get() override {
- return Port_;
- }
-
- private:
- THolder<TFileLock> Lock_;
- ui16 Port_;
- };
-
- std::pair<ui16, ui16> GetEphemeralRange() {
- // IANA suggestion
- std::pair<ui16, ui16> pair{(1 << 15) + (1 << 14), (1 << 16) - 1};
- #ifdef _linux_
- if (NFs::Exists("/proc/sys/net/ipv4/ip_local_port_range")) {
- TIFStream fileStream("/proc/sys/net/ipv4/ip_local_port_range");
- fileStream >> pair.first >> pair.second;
- }
- #endif
- #ifdef _darwin_
- ui32 first, last;
- size_t size;
- sysctlbyname("net.inet.ip.portrange.first", &first, &size, NULL, 0);
- sysctlbyname("net.inet.ip.portrange.last", &last, &size, NULL, 0);
- pair.first = first;
- pair.second = last;
- #endif
- return pair;
- }
-
- TVector<std::pair<ui16, ui16>> GetPortRanges() {
- TString givenRange = GetEnv("VALID_PORT_RANGE");
- TVector<std::pair<ui16, ui16>> ranges;
- if (givenRange.Contains(':')) {
- auto res = StringSplitter(givenRange).Split(':').Limit(2).ToList<TString>();
- ranges.emplace_back(FromString<ui16>(res.front()), FromString<ui16>(res.back()));
- } else {
- const ui16 firstValid = 1025;
- const ui16 lastValid = Max<ui16>();
-
- auto [firstEphemeral, lastEphemeral] = GetEphemeralRange();
- const ui16 firstInvalid = Max(firstEphemeral, firstValid);
- const ui16 lastInvalid = Min(lastEphemeral, lastValid);
-
- if (firstInvalid > firstValid)
- ranges.emplace_back(firstValid, firstInvalid - 1);
- if (lastInvalid < lastValid)
- ranges.emplace_back(lastInvalid + 1, lastValid);
- }
- return ranges;
- }
-
- class TPortManager {
- static constexpr size_t Retries = 20;
- public:
- TPortManager()
- : SyncDir_(GetEnv("PORT_SYNC_PATH"))
- , Ranges_(GetPortRanges())
- , TotalCount_(0)
- {
- if (!SyncDir_.IsDefined()) {
- SyncDir_ = TFsPath(GetSystemTempDir()) / "yandex_port_locks";
- }
- Y_VERIFY(SyncDir_.IsDefined());
- NFs::MakeDirectoryRecursive(SyncDir_);
-
- for (auto [left, right] : Ranges_) {
- TotalCount_ += right - left;
- }
- Y_VERIFY(0 != TotalCount_);
- }
-
- NTesting::TPortHolder GetFreePort() const {
- ui16 salt = RandomNumber<ui16>();
- for (ui16 attempt = 0; attempt < TotalCount_; ++attempt) {
- ui16 probe = (salt + attempt) % TotalCount_;
-
- for (auto [left, right] : Ranges_) {
- if (probe >= right - left)
- probe -= right - left;
- else {
- probe += left;
- break;
- }
- }
-
- auto port = TryAcquirePort(probe);
- if (port) {
- return NTesting::TPortHolder{std::move(port)};
- }
- }
-
- Y_FAIL("Cannot get free port!");
- }
-
- TVector<NTesting::TPortHolder> GetFreePortsRange(size_t count) const {
- Y_VERIFY(count > 0);
- TVector<NTesting::TPortHolder> ports(Reserve(count));
- for (size_t i = 0; i < Retries; ++i) {
- for (auto[left, right] : Ranges_) {
- if (right - left < count) {
- continue;
- }
- ui16 start = left + RandomNumber<ui16>((right - left) / 2);
- if (right - start < count) {
- continue;
- }
- for (ui16 probe = start; probe < right; ++probe) {
- auto port = TryAcquirePort(probe);
- if (port) {
- ports.emplace_back(std::move(port));
- } else {
- ports.clear();
- }
- if (ports.size() == count) {
- return ports;
- }
- }
- // Can't find required number of ports without gap in the current range
- ports.clear();
- }
- }
- Y_FAIL("Cannot get range of %zu ports!", count);
- }
-
- private:
- THolder<NTesting::IPort> TryAcquirePort(ui16 port) const {
- auto lock = MakeHolder<TFileLock>(TString(SyncDir_ / ::ToString(port)));
- if (!lock->TryAcquire()) {
- return nullptr;
- }
-
- TInet6StreamSocket sock;
- Y_VERIFY_SYSERROR(INVALID_SOCKET != static_cast<SOCKET>(sock));
-
- TSockAddrInet6 addr("::", port);
- if (sock.Bind(&addr) != 0) {
- lock->Release();
- Y_VERIFY(EADDRINUSE == LastSystemError(), "unexpected error: %d", LastSystemError());
- return nullptr;
- }
- return MakeHolder<TPortGuard>(port, std::move(lock));
- }
-
- private:
- TFsPath SyncDir_;
- TVector<std::pair<ui16, ui16>> Ranges_;
- size_t TotalCount_;
- };
-}
-
-namespace NTesting {
- TPortHolder GetFreePort() {
- return Singleton<TPortManager>()->GetFreePort();
- }
-
- namespace NLegacy {
- TVector<TPortHolder> GetFreePortsRange(size_t count) {
- return Singleton<TPortManager>()->GetFreePortsRange(count);
- }
- }
+ Y_VERIFY_SYSERROR(NFs::Remove(Lock_->GetName()));
+ }
+
+ ui16 Get() override {
+ return Port_;
+ }
+
+ private:
+ THolder<TFileLock> Lock_;
+ ui16 Port_;
+ };
+
+ std::pair<ui16, ui16> GetEphemeralRange() {
+ // IANA suggestion
+ std::pair<ui16, ui16> pair{(1 << 15) + (1 << 14), (1 << 16) - 1};
+ #ifdef _linux_
+ if (NFs::Exists("/proc/sys/net/ipv4/ip_local_port_range")) {
+ TIFStream fileStream("/proc/sys/net/ipv4/ip_local_port_range");
+ fileStream >> pair.first >> pair.second;
+ }
+ #endif
+ #ifdef _darwin_
+ ui32 first, last;
+ size_t size;
+ sysctlbyname("net.inet.ip.portrange.first", &first, &size, NULL, 0);
+ sysctlbyname("net.inet.ip.portrange.last", &last, &size, NULL, 0);
+ pair.first = first;
+ pair.second = last;
+ #endif
+ return pair;
+ }
+
+ TVector<std::pair<ui16, ui16>> GetPortRanges() {
+ TString givenRange = GetEnv("VALID_PORT_RANGE");
+ TVector<std::pair<ui16, ui16>> ranges;
+ if (givenRange.Contains(':')) {
+ auto res = StringSplitter(givenRange).Split(':').Limit(2).ToList<TString>();
+ ranges.emplace_back(FromString<ui16>(res.front()), FromString<ui16>(res.back()));
+ } else {
+ const ui16 firstValid = 1025;
+ const ui16 lastValid = Max<ui16>();
+
+ auto [firstEphemeral, lastEphemeral] = GetEphemeralRange();
+ const ui16 firstInvalid = Max(firstEphemeral, firstValid);
+ const ui16 lastInvalid = Min(lastEphemeral, lastValid);
+
+ if (firstInvalid > firstValid)
+ ranges.emplace_back(firstValid, firstInvalid - 1);
+ if (lastInvalid < lastValid)
+ ranges.emplace_back(lastInvalid + 1, lastValid);
+ }
+ return ranges;
+ }
+
+ class TPortManager {
+ static constexpr size_t Retries = 20;
+ public:
+ TPortManager()
+ : SyncDir_(GetEnv("PORT_SYNC_PATH"))
+ , Ranges_(GetPortRanges())
+ , TotalCount_(0)
+ {
+ if (!SyncDir_.IsDefined()) {
+ SyncDir_ = TFsPath(GetSystemTempDir()) / "yandex_port_locks";
+ }
+ Y_VERIFY(SyncDir_.IsDefined());
+ NFs::MakeDirectoryRecursive(SyncDir_);
+
+ for (auto [left, right] : Ranges_) {
+ TotalCount_ += right - left;
+ }
+ Y_VERIFY(0 != TotalCount_);
+ }
+
+ NTesting::TPortHolder GetFreePort() const {
+ ui16 salt = RandomNumber<ui16>();
+ for (ui16 attempt = 0; attempt < TotalCount_; ++attempt) {
+ ui16 probe = (salt + attempt) % TotalCount_;
+
+ for (auto [left, right] : Ranges_) {
+ if (probe >= right - left)
+ probe -= right - left;
+ else {
+ probe += left;
+ break;
+ }
+ }
+
+ auto port = TryAcquirePort(probe);
+ if (port) {
+ return NTesting::TPortHolder{std::move(port)};
+ }
+ }
+
+ Y_FAIL("Cannot get free port!");
+ }
+
+ TVector<NTesting::TPortHolder> GetFreePortsRange(size_t count) const {
+ Y_VERIFY(count > 0);
+ TVector<NTesting::TPortHolder> ports(Reserve(count));
+ for (size_t i = 0; i < Retries; ++i) {
+ for (auto[left, right] : Ranges_) {
+ if (right - left < count) {
+ continue;
+ }
+ ui16 start = left + RandomNumber<ui16>((right - left) / 2);
+ if (right - start < count) {
+ continue;
+ }
+ for (ui16 probe = start; probe < right; ++probe) {
+ auto port = TryAcquirePort(probe);
+ if (port) {
+ ports.emplace_back(std::move(port));
+ } else {
+ ports.clear();
+ }
+ if (ports.size() == count) {
+ return ports;
+ }
+ }
+ // Can't find required number of ports without gap in the current range
+ ports.clear();
+ }
+ }
+ Y_FAIL("Cannot get range of %zu ports!", count);
+ }
+
+ private:
+ THolder<NTesting::IPort> TryAcquirePort(ui16 port) const {
+ auto lock = MakeHolder<TFileLock>(TString(SyncDir_ / ::ToString(port)));
+ if (!lock->TryAcquire()) {
+ return nullptr;
+ }
+
+ TInet6StreamSocket sock;
+ Y_VERIFY_SYSERROR(INVALID_SOCKET != static_cast<SOCKET>(sock));
+
+ TSockAddrInet6 addr("::", port);
+ if (sock.Bind(&addr) != 0) {
+ lock->Release();
+ Y_VERIFY(EADDRINUSE == LastSystemError(), "unexpected error: %d", LastSystemError());
+ return nullptr;
+ }
+ return MakeHolder<TPortGuard>(port, std::move(lock));
+ }
+
+ private:
+ TFsPath SyncDir_;
+ TVector<std::pair<ui16, ui16>> Ranges_;
+ size_t TotalCount_;
+ };
+}
+
+namespace NTesting {
+ TPortHolder GetFreePort() {
+ return Singleton<TPortManager>()->GetFreePort();
+ }
+
+ namespace NLegacy {
+ TVector<TPortHolder> GetFreePortsRange(size_t count) {
+ return Singleton<TPortManager>()->GetFreePortsRange(count);
+ }
+ }
IOutputStream& operator<<(IOutputStream& out, const TPortHolder& port) {
return out << static_cast<ui16>(port);
}
-}
+}
diff --git a/library/cpp/testing/common/network.h b/library/cpp/testing/common/network.h
index 66fb2b0c40..eb4d32f3a1 100644
--- a/library/cpp/testing/common/network.h
+++ b/library/cpp/testing/common/network.h
@@ -1,52 +1,52 @@
-#pragma once
-
-#include <util/generic/ptr.h>
-#include <util/generic/vector.h>
-
-namespace NTesting {
-
- //@brief network port holder interface
- class IPort {
- public:
- virtual ~IPort() {}
-
- virtual ui16 Get() = 0;
- };
-
- class TPortHolder : private THolder<IPort> {
- using TBase = THolder<IPort>;
- public:
- using TBase::TBase;
- using TBase::Release;
- using TBase::Reset;
-
- operator ui16() const& {
- return (*this)->Get();
- }
-
- operator ui16() const&& = delete;
- };
-
+#pragma once
+
+#include <util/generic/ptr.h>
+#include <util/generic/vector.h>
+
+namespace NTesting {
+
+ //@brief network port holder interface
+ class IPort {
+ public:
+ virtual ~IPort() {}
+
+ virtual ui16 Get() = 0;
+ };
+
+ class TPortHolder : private THolder<IPort> {
+ using TBase = THolder<IPort>;
+ public:
+ using TBase::TBase;
+ using TBase::Release;
+ using TBase::Reset;
+
+ operator ui16() const& {
+ return (*this)->Get();
+ }
+
+ operator ui16() const&& = delete;
+ };
+
IOutputStream& operator<<(IOutputStream& out, const TPortHolder& port);
- //@brief Get first free port.
- [[nodiscard]] TPortHolder GetFreePort();
-
- namespace NLegacy {
- // Do not use this method, it needs only for TPortManager from unittests.
- // Returns continuous sequence of the specified number of ports.
- [[nodiscard]] TVector<TPortHolder> GetFreePortsRange(size_t count);
- }
-
- //@brief helper class for inheritance
- struct TFreePortOwner {
- TFreePortOwner() : Port_(GetFreePort()) {}
-
- ui16 GetPort() const {
- return Port_;
- }
-
- private:
- TPortHolder Port_;
- };
-}
+ //@brief Get first free port.
+ [[nodiscard]] TPortHolder GetFreePort();
+
+ namespace NLegacy {
+ // Do not use this method, it needs only for TPortManager from unittests.
+ // Returns continuous sequence of the specified number of ports.
+ [[nodiscard]] TVector<TPortHolder> GetFreePortsRange(size_t count);
+ }
+
+ //@brief helper class for inheritance
+ struct TFreePortOwner {
+ TFreePortOwner() : Port_(GetFreePort()) {}
+
+ ui16 GetPort() const {
+ return Port_;
+ }
+
+ private:
+ TPortHolder Port_;
+ };
+}
diff --git a/library/cpp/testing/common/probe.cpp b/library/cpp/testing/common/probe.cpp
index c0d7f46ba6..73f2fb6360 100644
--- a/library/cpp/testing/common/probe.cpp
+++ b/library/cpp/testing/common/probe.cpp
@@ -1 +1 @@
-#include "probe.h"
+#include "probe.h"
diff --git a/library/cpp/testing/common/probe.h b/library/cpp/testing/common/probe.h
index ba5a83a83e..19910979b5 100644
--- a/library/cpp/testing/common/probe.h
+++ b/library/cpp/testing/common/probe.h
@@ -1,140 +1,140 @@
#pragma once
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
namespace NTesting {
- ////////////////////////////////////////////////////////////////////////////////
-
- // Below there is a serie of probe classes for testing construction/destruction copying/moving of class.
- // for examples see tests in probe_ut.cpp
-
- struct TProbeState {
- int Constructors = 0;
- int Destructors = 0;
- int ShadowDestructors = 0;
- int CopyConstructors = 0;
- int CopyAssignments = 0;
- int MoveConstructors = 0;
- int MoveAssignments = 0;
- int Touches = 0;
-
- TProbeState() = default;
-
- void Reset() {
- *this = TProbeState{};
- }
- };
-
- // Used for probing the number of copies that occur if a type must be coerced.
- class TCoercibleToProbe {
- public:
- TProbeState* State;
- TProbeState* ShadowState;
-
- public:
- explicit TCoercibleToProbe(TProbeState* state)
- : State(state)
- , ShadowState(state)
- {}
-
- private:
- TCoercibleToProbe(const TCoercibleToProbe&);
- TCoercibleToProbe(TCoercibleToProbe&&);
- TCoercibleToProbe& operator=(const TCoercibleToProbe&);
- TCoercibleToProbe& operator=(TCoercibleToProbe&&);
- };
-
- // Used for probing the number of copies in an argument.
- class TProbe {
- public:
- TProbeState* State;
- TProbeState* ShadowState;
-
- public:
- static TProbe ExplicitlyCreateInvalidProbe() {
- return TProbe();
- }
-
- explicit TProbe(TProbeState* state)
- : State(state)
- , ShadowState(state)
- {
- Y_ASSERT(State);
- ++State->Constructors;
- }
-
- ~TProbe() {
- if (State) {
- ++State->Destructors;
- }
- if (ShadowState) {
- ++ShadowState->ShadowDestructors;
- }
- }
-
- TProbe(const TProbe& other)
- : State(other.State)
- , ShadowState(other.ShadowState)
- {
- Y_ASSERT(State);
- ++State->CopyConstructors;
- }
-
- TProbe(TProbe&& other)
- : State(other.State)
- , ShadowState(other.ShadowState)
- {
- Y_ASSERT(State);
- other.State = nullptr;
- ++State->MoveConstructors;
- }
-
- TProbe(const TCoercibleToProbe& other)
- : State(other.State)
- , ShadowState(other.ShadowState)
- {
- Y_ASSERT(State);
- ++State->CopyConstructors;
+ ////////////////////////////////////////////////////////////////////////////////
+
+ // Below there is a serie of probe classes for testing construction/destruction copying/moving of class.
+ // for examples see tests in probe_ut.cpp
+
+ struct TProbeState {
+ int Constructors = 0;
+ int Destructors = 0;
+ int ShadowDestructors = 0;
+ int CopyConstructors = 0;
+ int CopyAssignments = 0;
+ int MoveConstructors = 0;
+ int MoveAssignments = 0;
+ int Touches = 0;
+
+ TProbeState() = default;
+
+ void Reset() {
+ *this = TProbeState{};
+ }
+ };
+
+ // Used for probing the number of copies that occur if a type must be coerced.
+ class TCoercibleToProbe {
+ public:
+ TProbeState* State;
+ TProbeState* ShadowState;
+
+ public:
+ explicit TCoercibleToProbe(TProbeState* state)
+ : State(state)
+ , ShadowState(state)
+ {}
+
+ private:
+ TCoercibleToProbe(const TCoercibleToProbe&);
+ TCoercibleToProbe(TCoercibleToProbe&&);
+ TCoercibleToProbe& operator=(const TCoercibleToProbe&);
+ TCoercibleToProbe& operator=(TCoercibleToProbe&&);
+ };
+
+ // Used for probing the number of copies in an argument.
+ class TProbe {
+ public:
+ TProbeState* State;
+ TProbeState* ShadowState;
+
+ public:
+ static TProbe ExplicitlyCreateInvalidProbe() {
+ return TProbe();
+ }
+
+ explicit TProbe(TProbeState* state)
+ : State(state)
+ , ShadowState(state)
+ {
+ Y_ASSERT(State);
+ ++State->Constructors;
+ }
+
+ ~TProbe() {
+ if (State) {
+ ++State->Destructors;
+ }
+ if (ShadowState) {
+ ++ShadowState->ShadowDestructors;
+ }
+ }
+
+ TProbe(const TProbe& other)
+ : State(other.State)
+ , ShadowState(other.ShadowState)
+ {
+ Y_ASSERT(State);
+ ++State->CopyConstructors;
+ }
+
+ TProbe(TProbe&& other)
+ : State(other.State)
+ , ShadowState(other.ShadowState)
+ {
+ Y_ASSERT(State);
+ other.State = nullptr;
+ ++State->MoveConstructors;
+ }
+
+ TProbe(const TCoercibleToProbe& other)
+ : State(other.State)
+ , ShadowState(other.ShadowState)
+ {
+ Y_ASSERT(State);
+ ++State->CopyConstructors;
+ }
+
+ TProbe(TCoercibleToProbe&& other)
+ : State(other.State)
+ , ShadowState(other.ShadowState)
+ {
+ Y_ASSERT(State);
+ other.State = nullptr;
+ ++State->MoveConstructors;
+ }
+
+ TProbe& operator=(const TProbe& other) {
+ State = other.State;
+ ShadowState = other.ShadowState;
+ Y_ASSERT(State);
+ ++State->CopyAssignments;
+ return *this;
+ }
+
+ TProbe& operator=(TProbe&& other) {
+ State = other.State;
+ ShadowState = other.ShadowState;
+ Y_ASSERT(State);
+ other.State = nullptr;
+ ++State->MoveAssignments;
+ return *this;
}
-
- TProbe(TCoercibleToProbe&& other)
- : State(other.State)
- , ShadowState(other.ShadowState)
- {
- Y_ASSERT(State);
- other.State = nullptr;
- ++State->MoveConstructors;
+
+ void Touch() const {
+ Y_ASSERT(State);
+ ++State->Touches;
+ }
+
+ bool IsValid() const {
+ return nullptr != State;
}
- TProbe& operator=(const TProbe& other) {
- State = other.State;
- ShadowState = other.ShadowState;
- Y_ASSERT(State);
- ++State->CopyAssignments;
- return *this;
- }
-
- TProbe& operator=(TProbe&& other) {
- State = other.State;
- ShadowState = other.ShadowState;
- Y_ASSERT(State);
- other.State = nullptr;
- ++State->MoveAssignments;
- return *this;
- }
-
- void Touch() const {
- Y_ASSERT(State);
- ++State->Touches;
- }
-
- bool IsValid() const {
- return nullptr != State;
- }
-
- private:
- TProbe()
- : State(nullptr)
- {}
- };
+ private:
+ TProbe()
+ : State(nullptr)
+ {}
+ };
} // namespace NTesting
diff --git a/library/cpp/testing/common/scope.cpp b/library/cpp/testing/common/scope.cpp
index 5efa7cb0d2..c70d695c1b 100644
--- a/library/cpp/testing/common/scope.cpp
+++ b/library/cpp/testing/common/scope.cpp
@@ -1 +1 @@
-#include "scope.h"
+#include "scope.h"
diff --git a/library/cpp/testing/common/scope.h b/library/cpp/testing/common/scope.h
index af12bda3c4..a2ca0e77e4 100644
--- a/library/cpp/testing/common/scope.h
+++ b/library/cpp/testing/common/scope.h
@@ -1,39 +1,39 @@
-#pragma once
-
-#include <util/generic/string.h>
-#include <util/generic/vector.h>
-#include <util/system/env.h>
-
-#include <utility>
-
-namespace NTesting {
- // @brief Assigns new values to the given environment variables and restores old values upon destruction.
- // @note if there was no env variable with given name, it will be set to empty string upon destruction IGNIETFERRO-1486
- struct TScopedEnvironment {
- TScopedEnvironment(const TString& name, const TString& value)
- : PreviousState{1, {name, ::GetEnv(name)}}
- {
- ::SetEnv(name, value);
- }
-
- TScopedEnvironment(const TVector<std::pair<TString, TString>>& vars)
- : PreviousState(Reserve(vars.size()))
- {
- for (const auto& [k, v] : vars) {
- PreviousState.emplace_back(k, ::GetEnv(k));
- ::SetEnv(k, v);
- }
- }
-
- ~TScopedEnvironment() {
- for (const auto& [k, v] : PreviousState) {
- ::SetEnv(k, v);
- }
- }
-
- TScopedEnvironment(const TScopedEnvironment&) = delete;
- TScopedEnvironment& operator=(const TScopedEnvironment&) = delete;
- private:
- TVector<std::pair<TString, TString>> PreviousState;
- };
-}
+#pragma once
+
+#include <util/generic/string.h>
+#include <util/generic/vector.h>
+#include <util/system/env.h>
+
+#include <utility>
+
+namespace NTesting {
+ // @brief Assigns new values to the given environment variables and restores old values upon destruction.
+ // @note if there was no env variable with given name, it will be set to empty string upon destruction IGNIETFERRO-1486
+ struct TScopedEnvironment {
+ TScopedEnvironment(const TString& name, const TString& value)
+ : PreviousState{1, {name, ::GetEnv(name)}}
+ {
+ ::SetEnv(name, value);
+ }
+
+ TScopedEnvironment(const TVector<std::pair<TString, TString>>& vars)
+ : PreviousState(Reserve(vars.size()))
+ {
+ for (const auto& [k, v] : vars) {
+ PreviousState.emplace_back(k, ::GetEnv(k));
+ ::SetEnv(k, v);
+ }
+ }
+
+ ~TScopedEnvironment() {
+ for (const auto& [k, v] : PreviousState) {
+ ::SetEnv(k, v);
+ }
+ }
+
+ TScopedEnvironment(const TScopedEnvironment&) = delete;
+ TScopedEnvironment& operator=(const TScopedEnvironment&) = delete;
+ private:
+ TVector<std::pair<TString, TString>> PreviousState;
+ };
+}
diff --git a/library/cpp/testing/common/ut/env_ut.cpp b/library/cpp/testing/common/ut/env_ut.cpp
index 889e8073e8..2aed1e4a25 100644
--- a/library/cpp/testing/common/ut/env_ut.cpp
+++ b/library/cpp/testing/common/ut/env_ut.cpp
@@ -1,104 +1,104 @@
-#include <library/cpp/testing/common/env.h>
-#include <library/cpp/testing/common/scope.h>
+#include <library/cpp/testing/common/env.h>
+#include <library/cpp/testing/common/scope.h>
#include <library/cpp/testing/gtest/gtest.h>
-
-#include <util/folder/dirut.h>
+
+#include <util/folder/dirut.h>
#include <util/stream/file.h>
-#include <util/system/env.h>
-#include <util/system/execpath.h>
+#include <util/system/env.h>
+#include <util/system/execpath.h>
#include <util/system/fs.h>
-
-
-TEST(Runtime, ArcadiaSourceRoot) {
+
+
+TEST(Runtime, ArcadiaSourceRoot) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- {
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", tmpDir);
+ {
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, ArcadiaSourceRoot());
- }
- {
- NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "");
+ EXPECT_EQ(tmpDir, ArcadiaSourceRoot());
+ }
+ {
+ NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "");
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_FALSE(ArcadiaSourceRoot().empty());
- }
-}
-
-TEST(Runtime, BuildRoot) {
+ EXPECT_FALSE(ArcadiaSourceRoot().empty());
+ }
+}
+
+TEST(Runtime, BuildRoot) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- {
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", tmpDir);
+ {
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, BuildRoot());
- }
- {
- NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", "");
+ EXPECT_EQ(tmpDir, BuildRoot());
+ }
+ {
+ NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", "");
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_FALSE(BuildRoot().empty());
- }
-}
-
-TEST(Runtime, BinaryPath) {
+ EXPECT_FALSE(BuildRoot().empty());
+ }
+}
+
+TEST(Runtime, BinaryPath) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_TRUE(TFsPath(BinaryPath("library/cpp/testing/common/ut")).Exists());
-}
-
-TEST(Runtime, GetArcadiaTestsData) {
+ EXPECT_TRUE(TFsPath(BinaryPath("library/cpp/testing/common/ut")).Exists());
+}
+
+TEST(Runtime, GetArcadiaTestsData) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- {
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", tmpDir);
+ {
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, GetArcadiaTestsData());
- }
- {
- NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", "");
+ EXPECT_EQ(tmpDir, GetArcadiaTestsData());
+ }
+ {
+ NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", "");
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- auto path = GetArcadiaTestsData();
- // it is not error if path is empty
- const bool ok = (path.empty() || GetBaseName(path) == "arcadia_tests_data");
- EXPECT_TRUE(ok);
- }
-}
-
-TEST(Runtime, GetWorkPath) {
+ auto path = GetArcadiaTestsData();
+ // it is not error if path is empty
+ const bool ok = (path.empty() || GetBaseName(path) == "arcadia_tests_data");
+ EXPECT_TRUE(ok);
+ }
+}
+
+TEST(Runtime, GetWorkPath) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- {
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("TEST_WORK_PATH", tmpDir);
+ {
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("TEST_WORK_PATH", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, GetWorkPath());
- }
- {
- NTesting::TScopedEnvironment guard("TEST_WORK_PATH", "");
+ EXPECT_EQ(tmpDir, GetWorkPath());
+ }
+ {
+ NTesting::TScopedEnvironment guard("TEST_WORK_PATH", "");
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_TRUE(!GetWorkPath().empty());
- }
-}
-
-TEST(Runtime, GetOutputPath) {
+ EXPECT_TRUE(!GetWorkPath().empty());
+ }
+}
+
+TEST(Runtime, GetOutputPath) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(GetOutputPath().Basename(), "testing_out_stuff");
-}
-
-TEST(Runtime, GetRamDrivePath) {
+ EXPECT_EQ(GetOutputPath().Basename(), "testing_out_stuff");
+}
+
+TEST(Runtime, GetRamDrivePath) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("YA_TEST_RAM_DRIVE_PATH", tmpDir);
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("YA_TEST_RAM_DRIVE_PATH", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, GetRamDrivePath());
-}
-
-TEST(Runtime, GetOutputRamDrivePath) {
+ EXPECT_EQ(tmpDir, GetRamDrivePath());
+}
+
+TEST(Runtime, GetOutputRamDrivePath) {
NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename
- auto tmpDir = ::GetSystemTempDir();
- NTesting::TScopedEnvironment guard("YA_TEST_OUTPUT_RAM_DRIVE_PATH", tmpDir);
+ auto tmpDir = ::GetSystemTempDir();
+ NTesting::TScopedEnvironment guard("YA_TEST_OUTPUT_RAM_DRIVE_PATH", tmpDir);
Singleton<NPrivate::TTestEnv>()->ReInitialize();
- EXPECT_EQ(tmpDir, GetOutputRamDrivePath());
-}
+ EXPECT_EQ(tmpDir, GetOutputRamDrivePath());
+}
#ifdef _linux_
TEST(Runtime, GdbPath) {
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);
+ }
+ }
+}
diff --git a/library/cpp/testing/common/ut/scope_ut.cpp b/library/cpp/testing/common/ut/scope_ut.cpp
index 4bbbd6b41c..4fb82c2466 100644
--- a/library/cpp/testing/common/ut/scope_ut.cpp
+++ b/library/cpp/testing/common/ut/scope_ut.cpp
@@ -1,28 +1,28 @@
-#include <library/cpp/testing/common/scope.h>
-
-#include <util/system/env.h>
-
-#include <library/cpp/testing/gtest/gtest.h>
-
-TEST(TScopedEnvironment, SingleValue) {
- auto before = GetEnv("ARCADIA_SOURCE_ROOT");
- {
- NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "source");
- EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
- }
- EXPECT_EQ(before, GetEnv("ARCADIA_SOURCE_ROOT"));
-}
-
-TEST(TScopedEnvironment, MultiValue) {
- TVector<TString> before{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
- {
- NTesting::TScopedEnvironment guard{{
- {"ARCADIA_SOURCE_ROOT", "source"},
- {"ARCADIA_BUILD_ROOT", "build"},
- }};
- EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
- EXPECT_EQ("build", GetEnv("ARCADIA_BUILD_ROOT"));
- }
- TVector<TString> after{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
- EXPECT_EQ(before, after);
-}
+#include <library/cpp/testing/common/scope.h>
+
+#include <util/system/env.h>
+
+#include <library/cpp/testing/gtest/gtest.h>
+
+TEST(TScopedEnvironment, SingleValue) {
+ auto before = GetEnv("ARCADIA_SOURCE_ROOT");
+ {
+ NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "source");
+ EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
+ }
+ EXPECT_EQ(before, GetEnv("ARCADIA_SOURCE_ROOT"));
+}
+
+TEST(TScopedEnvironment, MultiValue) {
+ TVector<TString> before{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
+ {
+ NTesting::TScopedEnvironment guard{{
+ {"ARCADIA_SOURCE_ROOT", "source"},
+ {"ARCADIA_BUILD_ROOT", "build"},
+ }};
+ EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
+ EXPECT_EQ("build", GetEnv("ARCADIA_BUILD_ROOT"));
+ }
+ TVector<TString> after{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
+ EXPECT_EQ(before, after);
+}
diff --git a/library/cpp/testing/common/ut/ya.make b/library/cpp/testing/common/ut/ya.make
index fbe866c479..053aa38079 100644
--- a/library/cpp/testing/common/ut/ya.make
+++ b/library/cpp/testing/common/ut/ya.make
@@ -1,19 +1,19 @@
GTEST()
-OWNER(
- amatanhead
- bulatman
- thegeorg
- g:cpp-contrib
-)
-
-SRCS(
- env_ut.cpp
- network_ut.cpp
- scope_ut.cpp
-)
-
-PEERDIR(
- library/cpp/testing/common
-)
-
-END()
+OWNER(
+ amatanhead
+ bulatman
+ thegeorg
+ g:cpp-contrib
+)
+
+SRCS(
+ env_ut.cpp
+ network_ut.cpp
+ scope_ut.cpp
+)
+
+PEERDIR(
+ library/cpp/testing/common
+)
+
+END()
diff --git a/library/cpp/testing/common/ya.make b/library/cpp/testing/common/ya.make
index 1c3b68328e..2f4b0ce26e 100644
--- a/library/cpp/testing/common/ya.make
+++ b/library/cpp/testing/common/ya.make
@@ -1,23 +1,23 @@
-LIBRARY()
-
-OWNER(
- amatanhead
- bulatman
- thegeorg
- g:cpp-contrib
-)
-
-SRCS(
- env.cpp
- network.cpp
+LIBRARY()
+
+OWNER(
+ amatanhead
+ bulatman
+ thegeorg
+ g:cpp-contrib
+)
+
+SRCS(
+ env.cpp
+ network.cpp
probe.cpp
- scope.cpp
-)
-
+ scope.cpp
+)
+
PEERDIR(
library/cpp/json
)
-END()
-
-RECURSE_FOR_TESTS(ut)
+END()
+
+RECURSE_FOR_TESTS(ut)
diff --git a/library/cpp/testing/gmock_in_unittest/ya.make b/library/cpp/testing/gmock_in_unittest/ya.make
index e909ebeb2e..5de68ad98d 100644
--- a/library/cpp/testing/gmock_in_unittest/ya.make
+++ b/library/cpp/testing/gmock_in_unittest/ya.make
@@ -3,8 +3,8 @@ LIBRARY()
OWNER(galaxycrab)
PEERDIR(
- contrib/restricted/googletest/googlemock
- contrib/restricted/googletest/googletest
+ contrib/restricted/googletest/googlemock
+ contrib/restricted/googletest/googletest
library/cpp/testing/gtest_extensions
library/cpp/testing/unittest
)
diff --git a/library/cpp/testing/gtest_extensions/assertions.h b/library/cpp/testing/gtest_extensions/assertions.h
index 30b9c645ff..e8ea07b5df 100644
--- a/library/cpp/testing/gtest_extensions/assertions.h
+++ b/library/cpp/testing/gtest_extensions/assertions.h
@@ -2,8 +2,8 @@
#include <util/generic/string.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
/**
* Check that the given statement throws an exception of the given type,
diff --git a/library/cpp/testing/gtest_extensions/gtest_extensions.h b/library/cpp/testing/gtest_extensions/gtest_extensions.h
index 3c2800c2b6..e20532241e 100644
--- a/library/cpp/testing/gtest_extensions/gtest_extensions.h
+++ b/library/cpp/testing/gtest_extensions/gtest_extensions.h
@@ -3,4 +3,4 @@
#include "assertions.h"
#include "matchers.h"
#include "pretty_printers.h"
-#include "probe.h"
+#include "probe.h"
diff --git a/library/cpp/testing/gtest_extensions/matchers.h b/library/cpp/testing/gtest_extensions/matchers.h
index 01f26f54e4..044c1c3ee4 100644
--- a/library/cpp/testing/gtest_extensions/matchers.h
+++ b/library/cpp/testing/gtest_extensions/matchers.h
@@ -2,8 +2,8 @@
#include <util/generic/string.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
namespace testing {
/**
@@ -19,11 +19,11 @@ namespace testing {
: internal::MatcherBase<const TBasicStringBuf<T, TT>&>(impl) {
}
- template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<const TBasicStringBuf<T, TT>&>(std::forward<M>(m)) {
- }
-
+ template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
+ Matcher(M&& m)
+ : internal::MatcherBase<const TBasicStringBuf<T, TT>&>(std::forward<M>(m)) {
+ }
+
Matcher(const TBasicString<T, TT>& s) {
*this = Eq(TBasicStringBuf<T, TT>(s));
}
@@ -54,11 +54,11 @@ namespace testing {
: internal::MatcherBase<TBasicStringBuf<T, TT>>(impl) {
}
- template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<TBasicStringBuf<T, TT>>(std::forward<M>(m)) {
- }
-
+ template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
+ Matcher(M&& m)
+ : internal::MatcherBase<TBasicStringBuf<T, TT>>(std::forward<M>(m)) {
+ }
+
Matcher(const TBasicString<T, TT>& s) {
*this = Eq(TBasicString<T, TT>(s));
}
@@ -89,11 +89,11 @@ namespace testing {
*this = Eq(s);
}
- template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<const TBasicString<T, TT>&>(std::forward<M>(m)) {
- }
-
+ template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
+ Matcher(M&& m)
+ : internal::MatcherBase<const TBasicString<T, TT>&>(std::forward<M>(m)) {
+ }
+
Matcher(const T* s) {
*this = Eq(TBasicString<T, TT>(s));
}
@@ -116,11 +116,11 @@ namespace testing {
: internal::MatcherBase<TBasicString<T, TT>>(impl) {
}
- template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<TBasicString<T, TT>>(std::forward<M>(m)) {
- }
-
+ template <typename M, typename = typename std::remove_reference<M>::type::is_gtest_matcher>
+ Matcher(M&& m)
+ : internal::MatcherBase<TBasicString<T, TT>>(std::forward<M>(m)) {
+ }
+
Matcher(const TBasicString<T, TT>& s) {
*this = Eq(s);
}
diff --git a/library/cpp/testing/gtest_extensions/pretty_printers.h b/library/cpp/testing/gtest_extensions/pretty_printers.h
index 15f07e4fe8..14d8284446 100644
--- a/library/cpp/testing/gtest_extensions/pretty_printers.h
+++ b/library/cpp/testing/gtest_extensions/pretty_printers.h
@@ -8,8 +8,8 @@
#include <util/stream/str.h>
#include <util/datetime/base.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
/**
* Automatically define GTest pretty printer for type that can print itself to util's `IOutputStream`.
diff --git a/library/cpp/testing/gtest_extensions/probe.cpp b/library/cpp/testing/gtest_extensions/probe.cpp
index f8d59ebd6b..c3a49b9323 100644
--- a/library/cpp/testing/gtest_extensions/probe.cpp
+++ b/library/cpp/testing/gtest_extensions/probe.cpp
@@ -1,13 +1,13 @@
-#include "probe.h"
-
-#include <ostream>
-
+#include "probe.h"
+
+#include <ostream>
+
namespace testing {
- void PrintTo(const TProbeState& state, ::std::ostream* os) {
- int copies = state.CopyConstructors + state.CopyAssignments;
- int moves = state.MoveConstructors + state.MoveAssignments;
- *os << state.Constructors << " ctors, " << state.Destructors << " dtors; "
- << "copies: " << copies << " = " << state.CopyConstructors << " + " << state.CopyAssignments << "; "
- << "moves: " << moves << " = " << state.MoveConstructors << " + " << state.MoveAssignments;
- }
+ void PrintTo(const TProbeState& state, ::std::ostream* os) {
+ int copies = state.CopyConstructors + state.CopyAssignments;
+ int moves = state.MoveConstructors + state.MoveAssignments;
+ *os << state.Constructors << " ctors, " << state.Destructors << " dtors; "
+ << "copies: " << copies << " = " << state.CopyConstructors << " + " << state.CopyAssignments << "; "
+ << "moves: " << moves << " = " << state.MoveConstructors << " + " << state.MoveAssignments;
+ }
} // namespace testing
diff --git a/library/cpp/testing/gtest_extensions/probe.h b/library/cpp/testing/gtest_extensions/probe.h
index 3b18502555..7d1fee83d3 100644
--- a/library/cpp/testing/gtest_extensions/probe.h
+++ b/library/cpp/testing/gtest_extensions/probe.h
@@ -1,81 +1,81 @@
#pragma once
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#include <library/cpp/testing/common/probe.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
namespace testing {
using NTesting::TProbe;
using NTesting::TProbeState;
using NTesting::TCoercibleToProbe;
- // A helper functor which extracts from probe-like objectss their state.
- struct TProbableTraits {
- static const TProbeState& ExtractState(const TProbeState& probe) {
- return probe;
- }
+ // A helper functor which extracts from probe-like objectss their state.
+ struct TProbableTraits {
+ static const TProbeState& ExtractState(const TProbeState& probe) {
+ return probe;
+ }
- static const TProbeState& ExtractState(const TProbeState* probe) {
- return *probe;
- }
+ static const TProbeState& ExtractState(const TProbeState* probe) {
+ return *probe;
+ }
- static const TProbeState& ExtractState(const TProbe& probe) {
- return *probe.State;
- }
+ static const TProbeState& ExtractState(const TProbe& probe) {
+ return *probe.State;
+ }
- static const TProbeState& ExtractState(const TCoercibleToProbe& probe) {
- return *probe.State;
- }
- };
+ static const TProbeState& ExtractState(const TCoercibleToProbe& probe) {
+ return *probe.State;
+ }
+ };
- void PrintTo(const TProbeState& state, ::std::ostream* os);
+ void PrintTo(const TProbeState& state, ::std::ostream* os);
- inline void PrintTo(const TProbe& probe, ::std::ostream* os) {
- PrintTo(TProbableTraits::ExtractState(probe), os);
+ inline void PrintTo(const TProbe& probe, ::std::ostream* os) {
+ PrintTo(TProbableTraits::ExtractState(probe), os);
}
- inline void PrintTo(const TCoercibleToProbe& probe, ::std::ostream* os) {
- PrintTo(TProbableTraits::ExtractState(probe), os);
+ inline void PrintTo(const TCoercibleToProbe& probe, ::std::ostream* os) {
+ PrintTo(TProbableTraits::ExtractState(probe), os);
}
- MATCHER(IsAlive, "is alive") {
- Y_UNUSED(result_listener);
+ MATCHER(IsAlive, "is alive") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return state.Destructors < state.Constructors + state.CopyConstructors + state.CopyAssignments;
+ return state.Destructors < state.Constructors + state.CopyConstructors + state.CopyAssignments;
}
- MATCHER(IsDead, "is dead") {
- Y_UNUSED(result_listener);
+ MATCHER(IsDead, "is dead") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return state.Destructors == state.Constructors + state.CopyConstructors + state.CopyAssignments;
+ return state.Destructors == state.Constructors + state.CopyConstructors + state.CopyAssignments;
}
- MATCHER_P2(HasCopyMoveCounts, copyCount, moveCount, "" + \
- PrintToString(copyCount) + " copy constructors and " + \
- PrintToString(moveCount) + " move constructors were called") {
- Y_UNUSED(result_listener);
+ MATCHER_P2(HasCopyMoveCounts, copyCount, moveCount, "" + \
+ PrintToString(copyCount) + " copy constructors and " + \
+ PrintToString(moveCount) + " move constructors were called") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return state.CopyConstructors == copyCount && state.MoveConstructors == moveCount;
- }
+ return state.CopyConstructors == copyCount && state.MoveConstructors == moveCount;
+ }
- MATCHER(NoCopies, "no copies were made") {
- Y_UNUSED(result_listener);
+ MATCHER(NoCopies, "no copies were made") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return 0 == state.CopyConstructors && 0 == state.CopyAssignments;
- }
+ return 0 == state.CopyConstructors && 0 == state.CopyAssignments;
+ }
- MATCHER(NoMoves, "no moves were made") {
- Y_UNUSED(result_listener);
+ MATCHER(NoMoves, "no moves were made") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return 0 == state.MoveConstructors && 0 == state.MoveAssignments;
- }
+ return 0 == state.MoveConstructors && 0 == state.MoveAssignments;
+ }
- MATCHER(NoAssignments, "no assignments were made") {
- Y_UNUSED(result_listener);
+ MATCHER(NoAssignments, "no assignments were made") {
+ Y_UNUSED(result_listener);
const auto& state = TProbableTraits::ExtractState(arg);
- return 0 == state.CopyAssignments && 0 == state.MoveAssignments;
- }
+ return 0 == state.CopyAssignments && 0 == state.MoveAssignments;
+ }
}
diff --git a/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp b/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
index 7fb0fd7a21..81cdfd0427 100644
--- a/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
+++ b/library/cpp/testing/gtest_extensions/ut/gtest_extensions_ut.cpp
@@ -52,7 +52,7 @@ std::pair<bool, std::string> Match(T&& t, M&& m) {
}
TEST(Matchers, Throws) {
- auto matcher = testing::Throws<std::runtime_error>();
+ auto matcher = testing::Throws<std::runtime_error>();
{
std::stringstream ss;
@@ -78,7 +78,7 @@ TEST(Matchers, Throws) {
{
auto [matched, explanation] = Match([]() { throw 10; }, matcher);
EXPECT_FALSE(matched);
- EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
+ EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
}
{
@@ -89,7 +89,7 @@ TEST(Matchers, Throws) {
}
TEST(Matchers, ThrowsMessage) {
- auto matcher = testing::ThrowsMessage<std::runtime_error>(testing::HasSubstr("error message"));
+ auto matcher = testing::ThrowsMessage<std::runtime_error>(testing::HasSubstr("error message"));
{
std::stringstream ss;
@@ -122,7 +122,7 @@ TEST(Matchers, ThrowsMessage) {
{
auto [matched, explanation] = Match([]() { throw 10; }, matcher);
EXPECT_FALSE(matched);
- EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
+ EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
}
{
@@ -133,7 +133,7 @@ TEST(Matchers, ThrowsMessage) {
}
TEST(Matchers, ThrowsMessageHasSubstr) {
- auto matcher = testing::ThrowsMessage<std::runtime_error>(testing::HasSubstr("error message"));
+ auto matcher = testing::ThrowsMessage<std::runtime_error>(testing::HasSubstr("error message"));
{
std::stringstream ss;
@@ -166,7 +166,7 @@ TEST(Matchers, ThrowsMessageHasSubstr) {
{
auto [matched, explanation] = Match([]() { throw 10; }, matcher);
EXPECT_FALSE(matched);
- EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
+ EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
}
{
@@ -177,7 +177,7 @@ TEST(Matchers, ThrowsMessageHasSubstr) {
}
TEST(Matchers, ThrowsCondition) {
- auto matcher = testing::Throws<std::runtime_error>(
+ auto matcher = testing::Throws<std::runtime_error>(
testing::Property(&std::exception::what, testing::HasSubstr("error message")));
{
@@ -212,7 +212,7 @@ TEST(Matchers, ThrowsCondition) {
{
auto [matched, explanation] = Match([]() { throw 10; }, matcher);
EXPECT_FALSE(matched);
- EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
+ EXPECT_THAT(explanation, testing::HasSubstr("throws an exception of an unknown type"));
}
{
diff --git a/library/cpp/testing/gtest_extensions/ut/probe_ut.cpp b/library/cpp/testing/gtest_extensions/ut/probe_ut.cpp
index 428f313b9e..a9d53f896a 100644
--- a/library/cpp/testing/gtest_extensions/ut/probe_ut.cpp
+++ b/library/cpp/testing/gtest_extensions/ut/probe_ut.cpp
@@ -1,54 +1,54 @@
-#include <library/cpp/testing/gtest/gtest.h>
-
-using namespace testing;
-
-TEST(ProbeStateTest, Example) {
- // check that our test function does not make a copy of passed argument
- auto copyless = [](auto&& x) {
- TProbe p(std::move(x));
- p.Touch();
- return p;
- };
-
- TProbeState state;
- auto probe = copyless(TProbe(&state));
- EXPECT_EQ(1, state.Touches);
- EXPECT_THAT(state, HasCopyMoveCounts(0, 2));
-}
-
-TEST(ProbeTest, Construct) {
- TProbeState state;
- {
- TProbe probe(&state);
- EXPECT_THAT(state, IsAlive());
- }
- EXPECT_THAT(state, IsDead());
-}
-
-TEST(ProbeTest, Copy) {
- TProbeState state;
-
- TProbe probe(&state);
- TProbe copy(probe);
- EXPECT_THAT(state, HasCopyMoveCounts(1, 0));
- EXPECT_THAT(state, NoAssignments());
- EXPECT_THAT(state, NoMoves());
-
- TProbe copy2 = TProbe::ExplicitlyCreateInvalidProbe();
- copy2 = probe;
- EXPECT_EQ(1, state.CopyAssignments);
-}
-
-TEST(ProbeTest, Move) {
- TProbeState state;
- TProbe probe(&state);
- TProbe probe2(std::move(probe));
- EXPECT_FALSE(probe.IsValid());
- EXPECT_THAT(state, NoCopies());
-
- EXPECT_THAT(state, HasCopyMoveCounts(0, 1));
-
- TProbe probe3 = TProbe::ExplicitlyCreateInvalidProbe();
- probe3 = std::move(probe2);
- EXPECT_EQ(1, state.MoveAssignments);
-}
+#include <library/cpp/testing/gtest/gtest.h>
+
+using namespace testing;
+
+TEST(ProbeStateTest, Example) {
+ // check that our test function does not make a copy of passed argument
+ auto copyless = [](auto&& x) {
+ TProbe p(std::move(x));
+ p.Touch();
+ return p;
+ };
+
+ TProbeState state;
+ auto probe = copyless(TProbe(&state));
+ EXPECT_EQ(1, state.Touches);
+ EXPECT_THAT(state, HasCopyMoveCounts(0, 2));
+}
+
+TEST(ProbeTest, Construct) {
+ TProbeState state;
+ {
+ TProbe probe(&state);
+ EXPECT_THAT(state, IsAlive());
+ }
+ EXPECT_THAT(state, IsDead());
+}
+
+TEST(ProbeTest, Copy) {
+ TProbeState state;
+
+ TProbe probe(&state);
+ TProbe copy(probe);
+ EXPECT_THAT(state, HasCopyMoveCounts(1, 0));
+ EXPECT_THAT(state, NoAssignments());
+ EXPECT_THAT(state, NoMoves());
+
+ TProbe copy2 = TProbe::ExplicitlyCreateInvalidProbe();
+ copy2 = probe;
+ EXPECT_EQ(1, state.CopyAssignments);
+}
+
+TEST(ProbeTest, Move) {
+ TProbeState state;
+ TProbe probe(&state);
+ TProbe probe2(std::move(probe));
+ EXPECT_FALSE(probe.IsValid());
+ EXPECT_THAT(state, NoCopies());
+
+ EXPECT_THAT(state, HasCopyMoveCounts(0, 1));
+
+ TProbe probe3 = TProbe::ExplicitlyCreateInvalidProbe();
+ probe3 = std::move(probe2);
+ EXPECT_EQ(1, state.MoveAssignments);
+}
diff --git a/library/cpp/testing/gtest_extensions/ut/ya.make b/library/cpp/testing/gtest_extensions/ut/ya.make
index ca333b4905..39b41cecfd 100644
--- a/library/cpp/testing/gtest_extensions/ut/ya.make
+++ b/library/cpp/testing/gtest_extensions/ut/ya.make
@@ -10,7 +10,7 @@ OWNER(
SRCS(
gtest_extensions_ut.cpp
- probe_ut.cpp
+ probe_ut.cpp
)
PEERDIR(
diff --git a/library/cpp/testing/gtest_extensions/ya.make b/library/cpp/testing/gtest_extensions/ya.make
index 4537d0153f..e24e81e8bd 100644
--- a/library/cpp/testing/gtest_extensions/ya.make
+++ b/library/cpp/testing/gtest_extensions/ya.make
@@ -9,8 +9,8 @@ OWNER(
)
PEERDIR(
- contrib/restricted/googletest/googlemock
- contrib/restricted/googletest/googletest
+ contrib/restricted/googletest/googlemock
+ contrib/restricted/googletest/googletest
)
SRCS(
@@ -18,7 +18,7 @@ SRCS(
gtest_extensions.cpp
matchers.cpp
pretty_printers.cpp
- probe.cpp
+ probe.cpp
)
END()
diff --git a/library/cpp/testing/hook/README.md b/library/cpp/testing/hook/README.md
index ffab40a960..fac8b32ef5 100644
--- a/library/cpp/testing/hook/README.md
+++ b/library/cpp/testing/hook/README.md
@@ -1,25 +1,25 @@
-# Hook for google benchmark and gtest
-
-Y_TEST_HOOK_BEFORE_INIT - вызывается перед инициализацией соотвествующего фреймворка
-Y_TEST_HOOK_BEFORE_RUN - вызывается перед запуском тестов
-Y_TEST_HOOK_AFTER_RUN - вызывается всегда после завершения выполнения тестов,
- если этап инициализации был успешным
-
-## Примеры:
-
-```
-Y_TEST_HOOK_BEFORE_INIT(SetupMyApp) {
- // ваш код для выполнения перед инициализацией фреймворка
-}
-
-Y_TEST_HOOK_BEFORE_RUN(InitMyApp) {
- // ваш код для выполнения перед запуском тестов
-}
-
-Y_TEST_HOOK_AFTER_RUN(CleanMyApp) {
- // ваш код для выполнения после завершения тестов
-}
-```
-
-## Тесты:
-тесты лаунчерах соотвествующих фреймворков (gtest, gbenchmark и unittest)
+# Hook for google benchmark and gtest
+
+Y_TEST_HOOK_BEFORE_INIT - вызывается перед инициализацией соотвествующего фреймворка
+Y_TEST_HOOK_BEFORE_RUN - вызывается перед запуском тестов
+Y_TEST_HOOK_AFTER_RUN - вызывается всегда после завершения выполнения тестов,
+ если этап инициализации был успешным
+
+## Примеры:
+
+```
+Y_TEST_HOOK_BEFORE_INIT(SetupMyApp) {
+ // ваш код для выполнения перед инициализацией фреймворка
+}
+
+Y_TEST_HOOK_BEFORE_RUN(InitMyApp) {
+ // ваш код для выполнения перед запуском тестов
+}
+
+Y_TEST_HOOK_AFTER_RUN(CleanMyApp) {
+ // ваш код для выполнения после завершения тестов
+}
+```
+
+## Тесты:
+тесты лаунчерах соотвествующих фреймворков (gtest, gbenchmark и unittest)
diff --git a/library/cpp/testing/hook/hook.cpp b/library/cpp/testing/hook/hook.cpp
index f5daca11cb..b3c599da89 100644
--- a/library/cpp/testing/hook/hook.cpp
+++ b/library/cpp/testing/hook/hook.cpp
@@ -1,45 +1,45 @@
-#include "hook.h"
-
-namespace {
- NTesting::THook* BeforeInitHead = nullptr;
- NTesting::THook* BeforeRunHead = nullptr;
- NTesting::THook* AfterRunHead = nullptr;
-
- void RegisterHook(NTesting::THook*& head, NTesting::THook* hook) {
- hook->Next = head;
- head = hook;
- }
-
- void CallHooks(NTesting::THook* head) {
- while (nullptr != head) {
- if (nullptr != head->Fn) {
- (*head->Fn)();
- }
- head = head->Next;
- }
- }
-}
-
-void NTesting::THook::RegisterBeforeInit(NTesting::THook* hook) noexcept {
- RegisterHook(BeforeInitHead, hook);
-}
-
-void NTesting::THook::CallBeforeInit() {
- CallHooks(BeforeInitHead);
-}
-
-void NTesting::THook::RegisterBeforeRun(NTesting::THook* hook) noexcept {
- RegisterHook(BeforeRunHead, hook);
-}
-
-void NTesting::THook::CallBeforeRun() {
- CallHooks(BeforeRunHead);
-}
-
-void NTesting::THook::RegisterAfterRun(NTesting::THook* hook) noexcept {
- RegisterHook(AfterRunHead, hook);
-}
-
-void NTesting::THook::CallAfterRun() {
- CallHooks(AfterRunHead);
-}
+#include "hook.h"
+
+namespace {
+ NTesting::THook* BeforeInitHead = nullptr;
+ NTesting::THook* BeforeRunHead = nullptr;
+ NTesting::THook* AfterRunHead = nullptr;
+
+ void RegisterHook(NTesting::THook*& head, NTesting::THook* hook) {
+ hook->Next = head;
+ head = hook;
+ }
+
+ void CallHooks(NTesting::THook* head) {
+ while (nullptr != head) {
+ if (nullptr != head->Fn) {
+ (*head->Fn)();
+ }
+ head = head->Next;
+ }
+ }
+}
+
+void NTesting::THook::RegisterBeforeInit(NTesting::THook* hook) noexcept {
+ RegisterHook(BeforeInitHead, hook);
+}
+
+void NTesting::THook::CallBeforeInit() {
+ CallHooks(BeforeInitHead);
+}
+
+void NTesting::THook::RegisterBeforeRun(NTesting::THook* hook) noexcept {
+ RegisterHook(BeforeRunHead, hook);
+}
+
+void NTesting::THook::CallBeforeRun() {
+ CallHooks(BeforeRunHead);
+}
+
+void NTesting::THook::RegisterAfterRun(NTesting::THook* hook) noexcept {
+ RegisterHook(AfterRunHead, hook);
+}
+
+void NTesting::THook::CallAfterRun() {
+ CallHooks(AfterRunHead);
+}
diff --git a/library/cpp/testing/hook/hook.h b/library/cpp/testing/hook/hook.h
index 1287e946c0..c45289cb22 100644
--- a/library/cpp/testing/hook/hook.h
+++ b/library/cpp/testing/hook/hook.h
@@ -1,128 +1,128 @@
-#pragma once
-
-namespace NTesting {
- /**
- * Hook class and registration system.
- *
- * Default implementation of the `main` function for G_BENCHMARK and GTEST calls these hooks when executing.
- * This is a useful feature if you want to customize behaviour of the `main` function,
- * but you don't want to write `main` yourself.
- *
- * Hooks form an intrusive linked list that's built at application startup. Note that hooks execute
- * in arbitrary order.
- *
- * Use macros below to define hooks.
- */
- struct THook {
- using TFn = void (*)();
-
- TFn Fn = nullptr;
- THook* Next = nullptr;
-
- static void RegisterBeforeInit(THook* hook) noexcept;
-
- static void CallBeforeInit();
-
- struct TRegisterBeforeInit {
- explicit TRegisterBeforeInit(THook* hook) noexcept {
- THook::RegisterBeforeInit(hook);
- }
- };
-
- static void RegisterBeforeRun(THook* hook) noexcept;
-
- static void CallBeforeRun();
-
- struct TRegisterBeforeRun {
- explicit TRegisterBeforeRun(THook* hook) noexcept {
- THook::RegisterBeforeRun(hook);
- }
- };
-
- static void RegisterAfterRun(THook* hook) noexcept;
-
- static void CallAfterRun();
-
- struct TRegisterAfterRun {
- explicit TRegisterAfterRun(THook* hook) noexcept {
- THook::RegisterAfterRun(hook);
- }
- };
- };
-
- /**
- * Called right before initializing test programm
- *
- * This hook is intended for setting up default parameters. If you're doing initialization, consider
- * using `Y_TEST_HOOK_BEFORE_RUN` instead.
- *
- * *Note:* hooks execute in arbitrary order.
- *
- *
- * # Usage
- *
- * Instantiate this class in a cpp file. Pass a unique name for your hook,
- * implement body right after macro instantiation:
- *
- * ```
- * Y_TEST_HOOK_BEFORE_INIT(SetupParams) {
- * // hook code
- * }
- * ```
- */
-#define Y_TEST_HOOK_BEFORE_INIT(N) \
- void N(); \
- ::NTesting::THook N##Hook{&N, nullptr}; \
- ::NTesting::THook::TRegisterBeforeInit N##HookReg{&N##Hook}; \
- void N()
-
- /**
- * Called right before launching tests.
- *
- * Hooks execute in arbitrary order. As such, we recommend using this hook to set up an event listener,
- * and performing initialization and cleanup in the corresponding event handlers. This is better than performing
- * initialization and cleanup directly in the hook's code because it gives more control over
- * order in which initialization is performed.
- *
- *
- * # Usage
- *
- * Instantiate this class in a cpp file. Pass a unique name for your hook,
- * implement body right after macro instantiation:
- *
- * ```
- * Y_TEST_HOOK_BEFORE_RUN(InitMyApp) {
- * // hook code
- * }
- * ```
- */
-#define Y_TEST_HOOK_BEFORE_RUN(N) \
- void N(); \
- ::NTesting::THook N##Hook{&N, nullptr}; \
- ::NTesting::THook::TRegisterBeforeRun N##HookReg{&N##Hook}; \
- void N()
-
- /**
- * Called after all tests has finished, just before program exit.
- *
- * This hook is intended for simple cleanup routines that don't care about order in which hooks are executed.
- * For more complex cases, we recommend using `Y_TEST_HOOK_BEFORE_RUN`.
- *
- *
- * # Usage
- *
- * Instantiate this class in a cpp file. Pass a unique name for your hook,
- * implement body right after macro instantiation:
- *
- * ```
- * Y_TEST_HOOK_AFTER_RUN(StopMyApp) {
- * // hook code
- * }
- * ```
- */
-#define Y_TEST_HOOK_AFTER_RUN(N) \
- void N(); \
- ::NTesting::THook N##Hook{&N, nullptr}; \
- ::NTesting::THook::TRegisterAfterRun N##HookReg{&N##Hook}; \
- void N()
-}
+#pragma once
+
+namespace NTesting {
+ /**
+ * Hook class and registration system.
+ *
+ * Default implementation of the `main` function for G_BENCHMARK and GTEST calls these hooks when executing.
+ * This is a useful feature if you want to customize behaviour of the `main` function,
+ * but you don't want to write `main` yourself.
+ *
+ * Hooks form an intrusive linked list that's built at application startup. Note that hooks execute
+ * in arbitrary order.
+ *
+ * Use macros below to define hooks.
+ */
+ struct THook {
+ using TFn = void (*)();
+
+ TFn Fn = nullptr;
+ THook* Next = nullptr;
+
+ static void RegisterBeforeInit(THook* hook) noexcept;
+
+ static void CallBeforeInit();
+
+ struct TRegisterBeforeInit {
+ explicit TRegisterBeforeInit(THook* hook) noexcept {
+ THook::RegisterBeforeInit(hook);
+ }
+ };
+
+ static void RegisterBeforeRun(THook* hook) noexcept;
+
+ static void CallBeforeRun();
+
+ struct TRegisterBeforeRun {
+ explicit TRegisterBeforeRun(THook* hook) noexcept {
+ THook::RegisterBeforeRun(hook);
+ }
+ };
+
+ static void RegisterAfterRun(THook* hook) noexcept;
+
+ static void CallAfterRun();
+
+ struct TRegisterAfterRun {
+ explicit TRegisterAfterRun(THook* hook) noexcept {
+ THook::RegisterAfterRun(hook);
+ }
+ };
+ };
+
+ /**
+ * Called right before initializing test programm
+ *
+ * This hook is intended for setting up default parameters. If you're doing initialization, consider
+ * using `Y_TEST_HOOK_BEFORE_RUN` instead.
+ *
+ * *Note:* hooks execute in arbitrary order.
+ *
+ *
+ * # Usage
+ *
+ * Instantiate this class in a cpp file. Pass a unique name for your hook,
+ * implement body right after macro instantiation:
+ *
+ * ```
+ * Y_TEST_HOOK_BEFORE_INIT(SetupParams) {
+ * // hook code
+ * }
+ * ```
+ */
+#define Y_TEST_HOOK_BEFORE_INIT(N) \
+ void N(); \
+ ::NTesting::THook N##Hook{&N, nullptr}; \
+ ::NTesting::THook::TRegisterBeforeInit N##HookReg{&N##Hook}; \
+ void N()
+
+ /**
+ * Called right before launching tests.
+ *
+ * Hooks execute in arbitrary order. As such, we recommend using this hook to set up an event listener,
+ * and performing initialization and cleanup in the corresponding event handlers. This is better than performing
+ * initialization and cleanup directly in the hook's code because it gives more control over
+ * order in which initialization is performed.
+ *
+ *
+ * # Usage
+ *
+ * Instantiate this class in a cpp file. Pass a unique name for your hook,
+ * implement body right after macro instantiation:
+ *
+ * ```
+ * Y_TEST_HOOK_BEFORE_RUN(InitMyApp) {
+ * // hook code
+ * }
+ * ```
+ */
+#define Y_TEST_HOOK_BEFORE_RUN(N) \
+ void N(); \
+ ::NTesting::THook N##Hook{&N, nullptr}; \
+ ::NTesting::THook::TRegisterBeforeRun N##HookReg{&N##Hook}; \
+ void N()
+
+ /**
+ * Called after all tests has finished, just before program exit.
+ *
+ * This hook is intended for simple cleanup routines that don't care about order in which hooks are executed.
+ * For more complex cases, we recommend using `Y_TEST_HOOK_BEFORE_RUN`.
+ *
+ *
+ * # Usage
+ *
+ * Instantiate this class in a cpp file. Pass a unique name for your hook,
+ * implement body right after macro instantiation:
+ *
+ * ```
+ * Y_TEST_HOOK_AFTER_RUN(StopMyApp) {
+ * // hook code
+ * }
+ * ```
+ */
+#define Y_TEST_HOOK_AFTER_RUN(N) \
+ void N(); \
+ ::NTesting::THook N##Hook{&N, nullptr}; \
+ ::NTesting::THook::TRegisterAfterRun N##HookReg{&N##Hook}; \
+ void N()
+}
diff --git a/library/cpp/testing/hook/ya.make b/library/cpp/testing/hook/ya.make
index 9f15673651..db58f4e0ae 100644
--- a/library/cpp/testing/hook/ya.make
+++ b/library/cpp/testing/hook/ya.make
@@ -1,13 +1,13 @@
-LIBRARY()
-OWNER(
- amatanhead
- bulatman
- thegeorg
- g:cpp-contrib
-)
-
-SRCS(
- hook.cpp
-)
-
-END()
+LIBRARY()
+OWNER(
+ amatanhead
+ bulatman
+ thegeorg
+ g:cpp-contrib
+)
+
+SRCS(
+ hook.cpp
+)
+
+END()
diff --git a/library/cpp/testing/unittest/env.h b/library/cpp/testing/unittest/env.h
index ed4236e314..4807539ab2 100644
--- a/library/cpp/testing/unittest/env.h
+++ b/library/cpp/testing/unittest/env.h
@@ -1,3 +1,3 @@
-// just shortcut
-#include <library/cpp/testing/common/env.h>
+// just shortcut
+#include <library/cpp/testing/common/env.h>
diff --git a/library/cpp/testing/unittest/plugin.h b/library/cpp/testing/unittest/plugin.h
index abf70764d4..102f2c1469 100644
--- a/library/cpp/testing/unittest/plugin.h
+++ b/library/cpp/testing/unittest/plugin.h
@@ -3,7 +3,7 @@
#include <util/generic/ptr.h>
namespace NUnitTest {
- // Plugins are deprecated, please use Y_TEST_HOOK_* from library/cpp/hook/hook.h
+ // Plugins are deprecated, please use Y_TEST_HOOK_* from library/cpp/hook/hook.h
namespace NPlugin {
class IPlugin {
public:
diff --git a/library/cpp/testing/unittest/tests_data.cpp b/library/cpp/testing/unittest/tests_data.cpp
index d7c7a40a0f..b51cbc4b87 100644
--- a/library/cpp/testing/unittest/tests_data.cpp
+++ b/library/cpp/testing/unittest/tests_data.cpp
@@ -1,59 +1,59 @@
#include "tests_data.h"
#include "registar.h"
-#include <library/cpp/testing/common/network.h>
+#include <library/cpp/testing/common/network.h>
+
+#include <util/system/env.h>
+#include <util/system/mutex.h>
-#include <util/system/env.h>
-#include <util/system/mutex.h>
-
class TPortManager::TPortManagerImpl {
public:
- TPortManagerImpl(bool reservePortsForCurrentTest)
- : EnableReservePortsForCurrentTest(reservePortsForCurrentTest)
- , DisableRandomPorts(!GetEnv("NO_RANDOM_PORTS").empty())
+ TPortManagerImpl(bool reservePortsForCurrentTest)
+ : EnableReservePortsForCurrentTest(reservePortsForCurrentTest)
+ , DisableRandomPorts(!GetEnv("NO_RANDOM_PORTS").empty())
{
}
ui16 GetPort(ui16 port) {
- if (port && DisableRandomPorts) {
+ if (port && DisableRandomPorts) {
return port;
}
- TAtomicSharedPtr<NTesting::IPort> holder(NTesting::GetFreePort().Release());
- ReservePortForCurrentTest(holder);
+ TAtomicSharedPtr<NTesting::IPort> holder(NTesting::GetFreePort().Release());
+ ReservePortForCurrentTest(holder);
- TGuard<TMutex> g(Lock);
- ReservedPorts.push_back(holder);
- return holder->Get();
- }
+ TGuard<TMutex> g(Lock);
+ ReservedPorts.push_back(holder);
+ return holder->Get();
+ }
- ui16 GetUdpPort(ui16 port) {
- return GetPort(port);
- }
+ ui16 GetUdpPort(ui16 port) {
+ return GetPort(port);
+ }
- ui16 GetTcpPort(ui16 port) {
- return GetPort(port);
+ ui16 GetTcpPort(ui16 port) {
+ return GetPort(port);
}
ui16 GetTcpAndUdpPort(ui16 port) {
- return GetPort(port);
+ return GetPort(port);
}
ui16 GetPortsRange(const ui16 startPort, const ui16 range) {
- Y_UNUSED(startPort);
- auto ports = NTesting::NLegacy::GetFreePortsRange(range);
- ui16 first = ports[0];
+ Y_UNUSED(startPort);
+ auto ports = NTesting::NLegacy::GetFreePortsRange(range);
+ ui16 first = ports[0];
TGuard<TMutex> g(Lock);
- for (auto& port : ports) {
- ReservedPorts.emplace_back(port.Release());
- ReservePortForCurrentTest(ReservedPorts.back());
+ for (auto& port : ports) {
+ ReservedPorts.emplace_back(port.Release());
+ ReservePortForCurrentTest(ReservedPorts.back());
}
- return first;
+ return first;
}
private:
- void ReservePortForCurrentTest(const TAtomicSharedPtr<NTesting::IPort>& portGuard) {
- if (EnableReservePortsForCurrentTest) {
+ void ReservePortForCurrentTest(const TAtomicSharedPtr<NTesting::IPort>& portGuard) {
+ if (EnableReservePortsForCurrentTest) {
TTestBase* currentTest = NUnitTest::NPrivate::GetCurrentTest();
if (currentTest != nullptr) {
currentTest->RunAfterTest([guard = portGuard]() mutable {
@@ -65,13 +65,13 @@ private:
private:
TMutex Lock;
- TVector<TAtomicSharedPtr<NTesting::IPort>> ReservedPorts;
- const bool EnableReservePortsForCurrentTest;
- const bool DisableRandomPorts;
+ TVector<TAtomicSharedPtr<NTesting::IPort>> ReservedPorts;
+ const bool EnableReservePortsForCurrentTest;
+ const bool DisableRandomPorts;
};
-TPortManager::TPortManager(bool reservePortsForCurrentTest)
- : Impl_(new TPortManagerImpl(reservePortsForCurrentTest))
+TPortManager::TPortManager(bool reservePortsForCurrentTest)
+ : Impl_(new TPortManagerImpl(reservePortsForCurrentTest))
{
}
@@ -99,6 +99,6 @@ ui16 TPortManager::GetPortsRange(const ui16 startPort, const ui16 range) {
}
ui16 GetRandomPort() {
- TPortManager* pm = Singleton<TPortManager>(false);
+ TPortManager* pm = Singleton<TPortManager>(false);
return pm->GetPort();
}
diff --git a/library/cpp/testing/unittest/tests_data.h b/library/cpp/testing/unittest/tests_data.h
index ff542d2c64..6536bc1ae6 100644
--- a/library/cpp/testing/unittest/tests_data.h
+++ b/library/cpp/testing/unittest/tests_data.h
@@ -1,7 +1,7 @@
#pragma once
-#include <library/cpp/testing/common/env.h>
-
+#include <library/cpp/testing/common/env.h>
+
#include <util/generic/noncopyable.h>
#include <util/generic/ptr.h>
#include <util/generic/string.h>
@@ -29,7 +29,7 @@ void SetReuseAddressAndPort(const TSocketType& sock) {
class TPortManager: public TNonCopyable {
public:
- TPortManager(bool reservePortsForCurrentTest = true);
+ TPortManager(bool reservePortsForCurrentTest = true);
~TPortManager();
// Gets free TCP port
diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp
index a5b74ee801..305bc6b40f 100644
--- a/library/cpp/testing/unittest/utmain.cpp
+++ b/library/cpp/testing/unittest/utmain.cpp
@@ -7,13 +7,13 @@
#include <library/cpp/json/writer/json.h>
#include <library/cpp/json/writer/json_value.h>
#include <library/cpp/testing/common/env.h>
-#include <library/cpp/testing/hook/hook.h>
+#include <library/cpp/testing/hook/hook.h>
#include <util/datetime/base.h>
#include <util/generic/hash.h>
#include <util/generic/hash_set.h>
-#include <util/generic/scope.h>
+#include <util/generic/scope.h>
#include <util/generic/string.h>
#include <util/generic/yexception.h>
@@ -647,7 +647,7 @@ int NUnitTest::RunMain(int argc, char** argv) {
Y_VERIFY(!sigaction(SIGUSR2, &sa, nullptr));
}
#endif
- NTesting::THook::CallBeforeInit();
+ NTesting::THook::CallBeforeInit();
InitNetworkSubSystem();
try {
@@ -658,11 +658,11 @@ int NUnitTest::RunMain(int argc, char** argv) {
#ifndef UT_SKIP_EXCEPTIONS
try {
#endif
- NTesting::THook::CallBeforeRun();
- Y_DEFER { NTesting::THook::CallAfterRun(); };
-
+ NTesting::THook::CallBeforeRun();
+ Y_DEFER { NTesting::THook::CallAfterRun(); };
+
NPlugin::OnStartMain(argc, argv);
- Y_DEFER { NPlugin::OnStopMain(argc, argv); };
+ Y_DEFER { NPlugin::OnStopMain(argc, argv); };
TColoredProcessor processor(GetExecPath());
IOutputStream* listStream = &Cout;
@@ -749,18 +749,18 @@ int NUnitTest::RunMain(int argc, char** argv) {
TTestFactory::Instance().SetProcessor(&processor);
- unsigned ret;
+ unsigned ret;
for (;;) {
- ret = TTestFactory::Instance().Execute();
+ ret = TTestFactory::Instance().Execute();
if (!processor.GetIsForked() && ret && processor.GetPrintSummary()) {
Cerr << "SOME TESTS FAILED!!!!" << Endl;
}
- if (0 != ret || !processor.IsLoop()) {
- break;
+ if (0 != ret || !processor.IsLoop()) {
+ break;
}
}
- return ret;
+ return ret;
#ifndef UT_SKIP_EXCEPTIONS
} catch (...) {
Cerr << "caught exception in test suite(" << CurrentExceptionMessage() << ")" << Endl;
diff --git a/library/cpp/testing/unittest/ya.make b/library/cpp/testing/unittest/ya.make
index f291fec2cb..aaa4f2ba85 100644
--- a/library/cpp/testing/unittest/ya.make
+++ b/library/cpp/testing/unittest/ya.make
@@ -12,8 +12,8 @@ PEERDIR(
library/cpp/dbg_output
library/cpp/diff
library/cpp/json/writer
- library/cpp/testing/common
- library/cpp/testing/hook
+ library/cpp/testing/common
+ library/cpp/testing/hook
)
SRCS(
@@ -26,8 +26,8 @@ SRCS(
)
END()
-
-RECURSE_FOR_TESTS(
- fat
- ut
-)
+
+RECURSE_FOR_TESTS(
+ fat
+ ut
+)
diff --git a/library/cpp/testing/ya.make b/library/cpp/testing/ya.make
index 735b4f678b..6a57ac2ee6 100644
--- a/library/cpp/testing/ya.make
+++ b/library/cpp/testing/ya.make
@@ -1,5 +1,5 @@
RECURSE(
- common
+ common
benchmark
benchmark/examples
benchmark/examples/metrics
@@ -7,16 +7,16 @@ RECURSE(
boost_test
boost_test_main
dump_clang_coverage
- gbenchmark_main
+ gbenchmark_main
gmock
gmock_in_unittest
gmock_in_unittest/example_ut
gtest
- gtest_boost_extensions
+ gtest_boost_extensions
gtest_extensions
gtest_main
- gtest_protobuf
- hook
+ gtest_protobuf
+ hook
mock_server
unittest
unittest_main