aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:46 +0300
commit8cbc307de0221f84c80c42dcbe07d40727537e2c (patch)
tree625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/testing
parent30d1ef3941e0dc835be7609de5ebee66958f215a (diff)
downloadydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing')
-rw-r--r--library/cpp/testing/benchmark/bench.cpp368
-rw-r--r--library/cpp/testing/benchmark/bench.h66
-rw-r--r--library/cpp/testing/benchmark/examples/main.cpp82
-rw-r--r--library/cpp/testing/benchmark/examples/metrics/main.py12
-rw-r--r--library/cpp/testing/benchmark/examples/metrics/ya.make28
-rw-r--r--library/cpp/testing/benchmark/examples/ya.make10
-rw-r--r--library/cpp/testing/benchmark/main/main.cpp24
-rw-r--r--library/cpp/testing/benchmark/main/ya.make20
-rw-r--r--library/cpp/testing/benchmark/ya.make18
-rw-r--r--library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp12
-rw-r--r--library/cpp/testing/unittest/checks.cpp8
-rw-r--r--library/cpp/testing/unittest/example_ut.cpp4
-rw-r--r--library/cpp/testing/unittest/registar.cpp2
-rw-r--r--library/cpp/testing/unittest/registar.h30
-rw-r--r--library/cpp/testing/unittest/registar_ut.cpp32
-rw-r--r--library/cpp/testing/unittest/ut/main.cpp12
-rw-r--r--library/cpp/testing/unittest/utmain.cpp14
17 files changed, 371 insertions, 371 deletions
diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp
index 08d8708005..dc7f8b7856 100644
--- a/library/cpp/testing/benchmark/bench.cpp
+++ b/library/cpp/testing/benchmark/bench.cpp
@@ -1,7 +1,7 @@
#include "bench.h"
-#include <contrib/libs/re2/re2/re2.h>
-
+#include <contrib/libs/re2/re2/re2.h>
+
#include <library/cpp/colorizer/output.h>
#include <library/cpp/getopt/small/last_getopt.h>
#include <library/cpp/json/json_value.h>
@@ -9,7 +9,7 @@
#include <library/cpp/threading/poor_man_openmp/thread_helper.h>
#include <util/system/hp_timer.h>
-#include <util/system/info.h>
+#include <util/system/info.h>
#include <util/stream/output.h>
#include <util/datetime/base.h>
#include <util/random/random.h>
@@ -26,7 +26,7 @@
#include <util/system/yield.h>
using re2::RE2;
-
+
using namespace NBench;
using namespace NColorizer;
using namespace NLastGetopt;
@@ -47,7 +47,7 @@ namespace {
};
struct ITestRunner: public TIntrusiveListItem<ITestRunner> {
- virtual ~ITestRunner() = default;
+ virtual ~ITestRunner() = default;
void Register();
virtual TStringBuf Name() const noexcept = 0;
@@ -278,115 +278,115 @@ namespace {
F(params);
}, opts.TimeBudget, *this);
}
-
- enum EOutFormat {
- F_CONSOLE = 0 /* "console" */,
+
+ enum EOutFormat {
+ F_CONSOLE = 0 /* "console" */,
F_CSV /* "csv" */,
F_JSON /* "json" */
- };
-
+ };
+
TAdaptiveLock STDOUT_LOCK;
-
+
struct IReporter {
- virtual void Report(TResult&& result) = 0;
-
- virtual void Finish() {
- }
-
- virtual ~IReporter() {
- }
- };
-
+ virtual void Report(TResult&& result) = 0;
+
+ virtual void Finish() {
+ }
+
+ virtual ~IReporter() {
+ }
+ };
+
class TConsoleReporter: public IReporter {
- public:
+ public:
~TConsoleReporter() override {
- }
-
- void Report(TResult&& r) override {
- with_lock (STDOUT_LOCK) {
- Cout << r;
- }
- }
- };
-
+ }
+
+ void Report(TResult&& r) override {
+ with_lock (STDOUT_LOCK) {
+ Cout << r;
+ }
+ }
+ };
+
class TCSVReporter: public IReporter {
- public:
- TCSVReporter() {
+ public:
+ TCSVReporter() {
Cout << "Name\tSamples\tIterations\tRun_time\tPer_iteration_sec\tPer_iteration_cycles" << Endl;
- }
-
+ }
+
~TCSVReporter() override {
- }
-
- void Report(TResult&& r) override {
- with_lock (STDOUT_LOCK) {
- Cout << r.TestName
- << '\t' << r.Samples
- << '\t' << r.Iterations
- << '\t' << r.RunTime;
-
- Cout << '\t';
- if (r.CyclesPerIteration) {
- Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration);
- } else {
- Cout << '-';
- }
-
- Cout << '\t';
- if (r.SecondsPerIteration) {
- Cout << DoFmtTime(*r.SecondsPerIteration);
- } else {
- Cout << '-';
- }
-
- Cout << Endl;
- }
- }
- };
-
+ }
+
+ void Report(TResult&& r) override {
+ with_lock (STDOUT_LOCK) {
+ Cout << r.TestName
+ << '\t' << r.Samples
+ << '\t' << r.Iterations
+ << '\t' << r.RunTime;
+
+ Cout << '\t';
+ if (r.CyclesPerIteration) {
+ Cout << TCycleTimer::FmtTime(*r.CyclesPerIteration);
+ } else {
+ Cout << '-';
+ }
+
+ Cout << '\t';
+ if (r.SecondsPerIteration) {
+ Cout << DoFmtTime(*r.SecondsPerIteration);
+ } else {
+ Cout << '-';
+ }
+
+ Cout << Endl;
+ }
+ }
+ };
+
class TJSONReporter: public IReporter {
- public:
+ public:
~TJSONReporter() override {
- }
-
- void Report(TResult&& r) override {
- with_lock (ResultsLock_) {
- Results_.emplace_back(std::move(r));
- }
- }
-
- void Finish() override {
- NJson::TJsonValue report;
- auto& bench = report["benchmark"];
- bench.SetType(NJson::JSON_ARRAY);
-
- NJson::TJsonValue benchReport;
-
- for (const auto& result : Results_) {
- NJson::TJsonValue{}.Swap(benchReport);
- benchReport["name"] = result.TestName;
- benchReport["samples"] = result.Samples;
- benchReport["run_time"] = result.RunTime;
-
- if (result.CyclesPerIteration) {
- benchReport["per_iteration_cycles"] = *result.CyclesPerIteration;
- }
-
- if (result.SecondsPerIteration) {
- benchReport["per_iteration_secons"] = *result.SecondsPerIteration;
- }
-
- bench.AppendValue(benchReport);
- }
-
- Cout << report << Endl;
- }
-
- private:
- TAdaptiveLock ResultsLock_;
+ }
+
+ void Report(TResult&& r) override {
+ with_lock (ResultsLock_) {
+ Results_.emplace_back(std::move(r));
+ }
+ }
+
+ void Finish() override {
+ NJson::TJsonValue report;
+ auto& bench = report["benchmark"];
+ bench.SetType(NJson::JSON_ARRAY);
+
+ NJson::TJsonValue benchReport;
+
+ for (const auto& result : Results_) {
+ NJson::TJsonValue{}.Swap(benchReport);
+ benchReport["name"] = result.TestName;
+ benchReport["samples"] = result.Samples;
+ benchReport["run_time"] = result.RunTime;
+
+ if (result.CyclesPerIteration) {
+ benchReport["per_iteration_cycles"] = *result.CyclesPerIteration;
+ }
+
+ if (result.SecondsPerIteration) {
+ benchReport["per_iteration_secons"] = *result.SecondsPerIteration;
+ }
+
+ bench.AppendValue(benchReport);
+ }
+
+ Cout << report << Endl;
+ }
+
+ private:
+ TAdaptiveLock ResultsLock_;
TVector<TResult> Results_;
- };
-
+ };
+
class TOrderedReporter: public IReporter {
public:
TOrderedReporter(THolder<IReporter> slave)
@@ -421,22 +421,22 @@ namespace {
};
THolder<IReporter> MakeReporter(const EOutFormat type) {
- switch (type) {
- case F_CONSOLE:
- return MakeHolder<TConsoleReporter>();
-
- case F_CSV:
- return MakeHolder<TCSVReporter>();
+ switch (type) {
+ case F_CONSOLE:
+ return MakeHolder<TConsoleReporter>();
+
+ case F_CSV:
+ return MakeHolder<TCSVReporter>();
- case F_JSON:
- return MakeHolder<TJSONReporter>();
+ case F_JSON:
+ return MakeHolder<TJSONReporter>();
default:
break;
- }
+ }
return MakeHolder<TConsoleReporter>(); // make compiler happy
- }
+ }
THolder<IReporter> MakeOrderedReporter(const EOutFormat type) {
return MakeHolder<TOrderedReporter>(MakeReporter(type));
@@ -448,24 +448,24 @@ namespace {
}
}
}
-
-template <>
-EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) {
- const auto s = TStringBuf{data, len};
+
+template <>
+EOutFormat FromStringImpl<EOutFormat>(const char* data, size_t len) {
+ const auto s = TStringBuf{data, len};
if (TStringBuf("console") == s) {
- return F_CONSOLE;
+ return F_CONSOLE;
} else if (TStringBuf("csv") == s) {
- return F_CSV;
+ return F_CSV;
} else if (TStringBuf("json") == s) {
- return F_JSON;
- }
-
- ythrow TFromStringException{} << "failed to convert '" << s << '\'';
+ return F_JSON;
+ }
+
+ ythrow TFromStringException{} << "failed to convert '" << s << '\'';
}
template <>
-void Out<TResult>(IOutputStream& out, const TResult& r) {
+void Out<TResult>(IOutputStream& out, const TResult& r) {
out << "----------- " << LightRed() << r.TestName << Old() << " ---------------" << Endl
<< " samples: " << White() << r.Samples << Old() << Endl
<< " iterations: " << White() << r.Iterations << Old() << Endl
@@ -482,9 +482,9 @@ void Out<TResult>(IOutputStream& out, const TResult& r) {
}
NCpu::TRegistar::TRegistar(const char* name, TUserFunc func) {
- static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size");
+ static_assert(sizeof(TCpuBenchmark) + alignof(TCpuBenchmark) < sizeof(Buf), "fix Buf size");
- new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func);
+ new (AlignUp(Buf, alignof(TCpuBenchmark))) TCpuBenchmark(name, func);
}
namespace {
@@ -496,36 +496,36 @@ namespace {
opts.AddLongOption('b', "budget")
.StoreResult(&TimeBudget)
- .RequiredArgument("SEC")
+ .RequiredArgument("SEC")
.Optional()
.Help("overall time budget");
opts.AddLongOption('l', "list")
- .NoArgument()
- .StoreValue(&ListTests, true)
+ .NoArgument()
+ .StoreValue(&ListTests, true)
.Help("list all tests");
opts.AddLongOption('t', "threads")
.StoreResult(&Threads)
- .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS")
- .DefaultValue("1")
+ .OptionalValue(ToString((NSystemInfo::CachedNumberOfCpus() + 1) / 2), "JOBS")
+ .DefaultValue("1")
.Help("run benchmarks in parallel");
- opts.AddLongOption('f', "format")
+ opts.AddLongOption('f', "format")
.AddLongName("benchmark_format")
- .StoreResult(&OutFormat)
- .RequiredArgument("FORMAT")
- .DefaultValue("console")
- .Help("output format (console|csv|json)");
-
- opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests");
-
- const TOptsParseResult parseResult{&opts, argc, argv};
-
- for (const auto& regexp : parseResult.GetFreeArgs()) {
+ .StoreResult(&OutFormat)
+ .RequiredArgument("FORMAT")
+ .DefaultValue("console")
+ .Help("output format (console|csv|json)");
+
+ opts.SetFreeArgDefaultTitle("REGEXP", "RE2 regular expression to filter tests");
+
+ const TOptsParseResult parseResult{&opts, argc, argv};
+
+ for (const auto& regexp : parseResult.GetFreeArgs()) {
Filters.push_back(MakeHolder<RE2>(regexp.data(), RE2::Quiet));
- Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'");
- }
+ Y_ENSURE(Filters.back()->ok(), "incorrect RE2 expression '" << regexp << "'");
+ }
}
bool MatchFilters(const TStringBuf& name) const {
@@ -533,72 +533,72 @@ namespace {
return true;
}
- for (auto&& re : Filters) {
+ for (auto&& re : Filters) {
if (RE2::FullMatchN({name.data(), name.size()}, *re, nullptr, 0)) {
- return true;
- }
- }
-
- return false;
- }
-
+ return true;
+ }
+ }
+
+ return false;
+ }
+
bool ListTests = false;
double TimeBudget = -1.0;
TVector<THolder<RE2>> Filters;
size_t Threads = 0;
- EOutFormat OutFormat;
+ EOutFormat OutFormat;
};
}
-int NBench::Main(int argc, char** argv) {
- const TProgOpts opts(argc, argv);
+int NBench::Main(int argc, char** argv) {
+ const TProgOpts opts(argc, argv);
TVector<ITestRunner*> tests;
-
- for (auto&& it : Tests()) {
- if (opts.MatchFilters(it.Name())) {
- tests.push_back(&it);
+
+ for (auto&& it : Tests()) {
+ if (opts.MatchFilters(it.Name())) {
+ tests.push_back(&it);
}
- }
+ }
EnumerateTests(tests);
- if (opts.ListTests) {
- for (const auto* const it : tests) {
- Cout << it->Name() << Endl;
+ if (opts.ListTests) {
+ for (const auto* const it : tests) {
+ Cout << it->Name() << Endl;
}
- return 0;
- }
+ return 0;
+ }
- if (!tests) {
- return 0;
- }
+ if (!tests) {
+ return 0;
+ }
- double timeBudget = opts.TimeBudget;
+ double timeBudget = opts.TimeBudget;
- if (timeBudget < 0) {
+ if (timeBudget < 0) {
timeBudget = 5.0 * tests.size();
- }
+ }
const TOptions testOpts = {timeBudget / tests.size()};
const auto reporter = MakeOrderedReporter(opts.OutFormat);
std::function<void(ITestRunner**)> func = [&](ITestRunner** it) {
- auto&& res = (*it)->Run(testOpts);
+ auto&& res = (*it)->Run(testOpts);
- reporter->Report(std::move(res));
- };
-
- if (opts.Threads > 1) {
- NYmp::SetThreadCount(opts.Threads);
+ reporter->Report(std::move(res));
+ };
+
+ if (opts.Threads > 1) {
+ NYmp::SetThreadCount(opts.Threads);
NYmp::ParallelForStaticChunk(tests.data(), tests.data() + tests.size(), 1, func);
- } else {
- for (auto it : tests) {
- func(&it);
- }
+ } else {
+ for (auto it : tests) {
+ func(&it);
+ }
}
-
- reporter->Finish();
-
- return 0;
+
+ reporter->Finish();
+
+ return 0;
}
diff --git a/library/cpp/testing/benchmark/bench.h b/library/cpp/testing/benchmark/bench.h
index 21551ad0dd..5773fc1534 100644
--- a/library/cpp/testing/benchmark/bench.h
+++ b/library/cpp/testing/benchmark/bench.h
@@ -26,62 +26,62 @@ namespace NBench {
/**
* Functions that states "I can read and write everywhere in memory".
- *
- * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call,
- * and force memory reads after it's call.
- */
- void Clobber();
-
+ *
+ * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call,
+ * and force memory reads after it's call.
+ */
+ void Clobber();
+
/**
* Forces whatever `p` points to be in memory and not in register.
- *
- * @param Pointer to data.
- */
- template <typename T>
- void Escape(T* p);
-
-#if defined(__GNUC__)
- Y_FORCE_INLINE void Clobber() {
+ *
+ * @param Pointer to data.
+ */
+ template <typename T>
+ void Escape(T* p);
+
+#if defined(__GNUC__)
+ Y_FORCE_INLINE void Clobber() {
asm volatile(""
:
:
: "memory");
- }
+ }
#elif defined(_MSC_VER)
Y_FORCE_INLINE void Clobber() {
_ReadWriteBarrier();
}
-#else
- Y_FORCE_INLINE void Clobber() {
- }
-#endif
-
-#if defined(__GNUC__)
- template <typename T>
- Y_FORCE_INLINE void Escape(T* p) {
+#else
+ Y_FORCE_INLINE void Clobber() {
+ }
+#endif
+
+#if defined(__GNUC__)
+ template <typename T>
+ Y_FORCE_INLINE void Escape(T* p) {
asm volatile(""
:
: "g"(p)
: "memory");
- }
-#else
- template <typename T>
- Y_FORCE_INLINE void Escape(T*) {
- }
-#endif
-
+ }
+#else
+ template <typename T>
+ Y_FORCE_INLINE void Escape(T*) {
+ }
+#endif
+
/**
* Use this function to prevent unused variables elimination.
*
* @param Unused variable (e.g. return value of benchmarked function).
*/
- template <typename T>
+ template <typename T>
Y_FORCE_INLINE void DoNotOptimize(T&& datum) {
::DoNotOptimizeAway(std::forward<T>(datum));
}
-
- int Main(int argc, char** argv);
+
+ int Main(int argc, char** argv);
}
#define Y_CPU_BENCHMARK(name, cnt) \
diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp
index ddd8b05ffc..745e636d4c 100644
--- a/library/cpp/testing/benchmark/examples/main.cpp
+++ b/library/cpp/testing/benchmark/examples/main.cpp
@@ -120,9 +120,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal1, iface) {
for (auto i : xrange<size_t>(0, iface.Iterations())) {
(void)i;
- NBench::Escape(&x);
+ NBench::Escape(&x);
Y_DO_NOT_OPTIMIZE_AWAY(FS1(x));
- NBench::Clobber();
+ NBench::Clobber();
}
}
@@ -131,9 +131,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef1, iface) {
for (auto i : xrange<size_t>(0, iface.Iterations())) {
(void)i;
- NBench::Escape(&x);
+ NBench::Escape(&x);
Y_DO_NOT_OPTIMIZE_AWAY(FS2(x));
- NBench::Clobber();
+ NBench::Clobber();
}
}
@@ -143,10 +143,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal2, iface) {
for (auto i : xrange<size_t>(0, iface.Iterations())) {
(void)i;
- NBench::Escape(&x);
- NBench::Escape(&y);
+ NBench::Escape(&x);
+ NBench::Escape(&y);
Y_DO_NOT_OPTIMIZE_AWAY(FS1_2(x, y));
- NBench::Clobber();
+ NBench::Clobber();
}
}
@@ -156,10 +156,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef2, iface) {
for (auto i : xrange<size_t>(0, iface.Iterations())) {
(void)i;
- NBench::Escape(&x);
- NBench::Escape(&y);
+ NBench::Escape(&x);
+ NBench::Escape(&y);
Y_DO_NOT_OPTIMIZE_AWAY(FS2_2(x, y));
- NBench::Clobber();
+ NBench::Clobber();
}
}
@@ -181,35 +181,35 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) {
Y_DO_NOT_OPTIMIZE_AWAY(FFF(i, i));
}
}
-
-/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly:
- * @code
- * │ push %rbp
- * │ mov %rsp,%rbp
- * │ push %rbx
- * │ push %rax
- * │ mov (%rdi),%rbx
- * │ test %rbx,%rbx
- * │ ↓ je 25
- * │ xor %edi,%edi
- * │ xor %esi,%esi
+
+/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly:
+ * @code
+ * │ push %rbp
+ * │ mov %rsp,%rbp
+ * │ push %rbx
+ * │ push %rax
+ * │ mov (%rdi),%rbx
+ * │ test %rbx,%rbx
+ * │ ↓ je 25
+ * │ xor %edi,%edi
+ * │ xor %esi,%esi
* │ → callq FS1(TBasicStringBuf<char, std::char_traits<char
- * │ nop
- * 100.00 │20:┌─→dec %rbx
- * │ └──jne 20
- * │25: add $0x8,%rsp
- * │ pop %rbx
- * │ pop %rbp
- * │ ← retq
- * @endcode
- *
- * So, this benchmark is measuring empty loop!
- */
-Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) {
- TStringBuf x;
-
- for (auto i : xrange<size_t>(0, iface.Iterations())) {
- (void)i;
- Y_DO_NOT_OPTIMIZE_AWAY(FS1(x));
- }
-}
+ * │ nop
+ * 100.00 │20:┌─→dec %rbx
+ * │ └──jne 20
+ * │25: add $0x8,%rsp
+ * │ pop %rbx
+ * │ pop %rbp
+ * │ ← retq
+ * @endcode
+ *
+ * So, this benchmark is measuring empty loop!
+ */
+Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) {
+ TStringBuf x;
+
+ for (auto i : xrange<size_t>(0, iface.Iterations())) {
+ (void)i;
+ Y_DO_NOT_OPTIMIZE_AWAY(FS1(x));
+ }
+}
diff --git a/library/cpp/testing/benchmark/examples/metrics/main.py b/library/cpp/testing/benchmark/examples/metrics/main.py
index 8f9d9d06ae..d826450400 100644
--- a/library/cpp/testing/benchmark/examples/metrics/main.py
+++ b/library/cpp/testing/benchmark/examples/metrics/main.py
@@ -1,7 +1,7 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
- metrics.set_benchmark(yc.execute_benchmark(
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
+ metrics.set_benchmark(yc.execute_benchmark(
'library/cpp/testing/benchmark/examples/examples',
- threads=8))
+ threads=8))
diff --git a/library/cpp/testing/benchmark/examples/metrics/ya.make b/library/cpp/testing/benchmark/examples/metrics/ya.make
index a9dbdca9fa..a2c773a2d0 100644
--- a/library/cpp/testing/benchmark/examples/metrics/ya.make
+++ b/library/cpp/testing/benchmark/examples/metrics/ya.make
@@ -1,20 +1,20 @@
-OWNER(
- pg
- yazevnul
-)
-
+OWNER(
+ pg
+ yazevnul
+)
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(library/cpp/testing/benchmark/examples)
-
-END()
+
+END()
diff --git a/library/cpp/testing/benchmark/examples/ya.make b/library/cpp/testing/benchmark/examples/ya.make
index 7e696e127a..d0d5bdca2c 100644
--- a/library/cpp/testing/benchmark/examples/ya.make
+++ b/library/cpp/testing/benchmark/examples/ya.make
@@ -1,8 +1,8 @@
-OWNER(
- pg
- yazevnul
-)
-
+OWNER(
+ pg
+ yazevnul
+)
+
Y_BENCHMARK()
SRCS(
diff --git a/library/cpp/testing/benchmark/main/main.cpp b/library/cpp/testing/benchmark/main/main.cpp
index aabcb89c43..b464c79023 100644
--- a/library/cpp/testing/benchmark/main/main.cpp
+++ b/library/cpp/testing/benchmark/main/main.cpp
@@ -1,16 +1,16 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/yexception.h>
-#include <util/stream/output.h>
-
-#include <cstdlib>
-
-int main(int argc, char** argv) {
- try {
- return NBench::Main(argc, argv);
+
+#include <util/generic/yexception.h>
+#include <util/stream/output.h>
+
+#include <cstdlib>
+
+int main(int argc, char** argv) {
+ try {
+ return NBench::Main(argc, argv);
} catch (...) {
- Cerr << CurrentExceptionMessage() << Endl;
- }
+ Cerr << CurrentExceptionMessage() << Endl;
+ }
return EXIT_FAILURE;
-}
+}
diff --git a/library/cpp/testing/benchmark/main/ya.make b/library/cpp/testing/benchmark/main/ya.make
index d00cdcf9fc..a434d42675 100644
--- a/library/cpp/testing/benchmark/main/ya.make
+++ b/library/cpp/testing/benchmark/main/ya.make
@@ -1,16 +1,16 @@
-LIBRARY()
-
+LIBRARY()
+
OWNER(
pg
yazevnul
)
-
-SRCS(
+
+SRCS(
GLOBAL main.cpp
-)
-
-PEERDIR(
+)
+
+PEERDIR(
library/cpp/testing/benchmark
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/testing/benchmark/ya.make b/library/cpp/testing/benchmark/ya.make
index f42be80698..661e160238 100644
--- a/library/cpp/testing/benchmark/ya.make
+++ b/library/cpp/testing/benchmark/ya.make
@@ -4,19 +4,19 @@ OWNER(
pg
yazevnul
)
-
-SRCS(
+
+SRCS(
bench.cpp
dummy.cpp
-)
-
-PEERDIR(
- contrib/libs/re2
+)
+
+PEERDIR(
+ contrib/libs/re2
library/cpp/colorizer
library/cpp/getopt/small
library/cpp/json
library/cpp/linear_regression
library/cpp/threading/poor_man_openmp
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp
index 97f19050e4..9d0a72fb47 100644
--- a/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp
+++ b/library/cpp/testing/gmock_in_unittest/example_ut/example_ut.cpp
@@ -27,8 +27,8 @@ public:
using namespace testing;
-Y_UNIT_TEST_SUITE(TExampleGMockTest) {
- Y_UNIT_TEST(TSimpleTest) {
+Y_UNIT_TEST_SUITE(TExampleGMockTest) {
+ Y_UNIT_TEST(TSimpleTest) {
TTestMock mock;
EXPECT_CALL(mock, Func1())
.Times(AtLeast(1));
@@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) {
}
}
- Y_UNIT_TEST(TNonExpectedCallTest) {
+ Y_UNIT_TEST(TNonExpectedCallTest) {
TTestMock mock;
EXPECT_CALL(mock, Func1())
.Times(AtMost(1));
@@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) {
}
}
- Y_UNIT_TEST(TReturnValuesTest) {
+ Y_UNIT_TEST(TReturnValuesTest) {
TTestMock mock;
EXPECT_CALL(mock, Func2(TString("1")))
.WillOnce(Return(1))
@@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) {
}
}
- Y_UNIT_TEST(TStrictCallSequenceTest) {
+ Y_UNIT_TEST(TStrictCallSequenceTest) {
TTestMock mock;
{
InSequence seq;
@@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TExampleGMockTest) {
}
}
- Y_UNIT_TEST(TUninterestingMethodIsFailureTest) {
+ Y_UNIT_TEST(TUninterestingMethodIsFailureTest) {
StrictMock<TTestMock> mock;
EXPECT_CALL(mock, Func1())
.Times(1);
diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp
index c5712ae9d2..70d6bb3410 100644
--- a/library/cpp/testing/unittest/checks.cpp
+++ b/library/cpp/testing/unittest/checks.cpp
@@ -1,5 +1,5 @@
#include <util/generic/string.h>
-#include <util/string/type.h>
+#include <util/string/type.h>
bool CheckExceptionMessage(const char* msg, TString& err) {
static const char* badMsg[] = {
@@ -10,7 +10,7 @@ bool CheckExceptionMessage(const char* msg, TString& err) {
err.clear();
- if (msg == nullptr) {
+ if (msg == nullptr) {
err = "Error message is null";
return false;
}
@@ -20,8 +20,8 @@ bool CheckExceptionMessage(const char* msg, TString& err) {
return false;
}
- for (auto& i : badMsg) {
- if (strstr(msg, i) != nullptr) {
+ for (auto& i : badMsg) {
+ if (strstr(msg, i) != nullptr) {
err = "Invalid error message: " + TString(msg);
return false;
}
diff --git a/library/cpp/testing/unittest/example_ut.cpp b/library/cpp/testing/unittest/example_ut.cpp
index bcc1ce33f0..e53d6a30fb 100644
--- a/library/cpp/testing/unittest/example_ut.cpp
+++ b/library/cpp/testing/unittest/example_ut.cpp
@@ -4,8 +4,8 @@
* just copy-paste it for good start point
*/
-Y_UNIT_TEST_SUITE(TUnitTest) {
- Y_UNIT_TEST(TestEqual) {
+Y_UNIT_TEST_SUITE(TUnitTest) {
+ Y_UNIT_TEST(TestEqual) {
UNIT_ASSERT_EQUAL(0, 0);
UNIT_ASSERT_EQUAL(1, 1);
}
diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp
index 3679b768ed..945f70d1de 100644
--- a/library/cpp/testing/unittest/registar.cpp
+++ b/library/cpp/testing/unittest/registar.cpp
@@ -59,7 +59,7 @@ void ::NUnitTest::SetRaiseErrorHandler(::NUnitTest::TRaiseErrorHandler handler)
}
void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) {
- Y_VERIFY(UnittestThread != unittestThread, "state check");
+ Y_VERIFY(UnittestThread != unittestThread, "state check");
UnittestThread = unittestThread;
}
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 44517a0092..8fb8f95e25 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -293,7 +293,7 @@ private: \
/* If you see this message - delete multiple UNIT_TEST(TestName) with same TestName. */ \
/* It's forbidden to declare same test twice because it breaks --fork-tests logic. */ \
int You_have_declared_test_##F##_multiple_times_This_is_forbidden; \
- Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden);
+ Y_UNUSED(You_have_declared_test_##F##_multiple_times_This_is_forbidden);
#define UNIT_TEST_RUN(F, FF, context) \
this->BeforeTest((#F)); \
@@ -914,7 +914,7 @@ public: \
#define UNIT_TEST_SUITE_REGISTRATION(T) \
static const ::NUnitTest::TTestBaseFactory<T> Y_GENERATE_UNIQUE_ID(UTREG_);
-#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \
+#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \
namespace NTestSuite##N { \
class TCurrentTestCase: public F { \
}; \
@@ -982,12 +982,12 @@ public: \
} \
namespace NTestSuite##N
-#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase)
-#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase)
-#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F)
-#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase)
+#define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase)
+#define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase)
+#define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F)
+#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase)
-#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
+#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
struct TTestCase##N : public F { \
TTestCase##N() \
: F() \
@@ -1007,21 +1007,21 @@ public: \
}; \
static const TTestRegistration##N testRegistration##N;
-#define Y_UNIT_TEST_IMPL(N, FF, F) \
- Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
+#define Y_UNIT_TEST_IMPL(N, FF, F) \
+ Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED)
-#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase)
-#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F)
-#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase)
+#define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase)
+#define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F)
+#define SIMPLE_UNIT_FORKED_TEST(N) Y_UNIT_TEST_IMPL(N, true, TCurrentTestCase)
-#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \
+#define Y_UNIT_TEST_SUITE_IMPLEMENTATION(N) \
namespace NTestSuite##N
-#define Y_UNIT_TEST_DECLARE(N) \
+#define Y_UNIT_TEST_DECLARE(N) \
struct TTestCase##N
-#define Y_UNIT_TEST_FRIEND(N, T) \
+#define Y_UNIT_TEST_FRIEND(N, T) \
friend NTestSuite##N::TTestCase##T \
TString RandomString(size_t len, ui32 seed = 0);
diff --git a/library/cpp/testing/unittest/registar_ut.cpp b/library/cpp/testing/unittest/registar_ut.cpp
index 1f36d53abb..46b455281b 100644
--- a/library/cpp/testing/unittest/registar_ut.cpp
+++ b/library/cpp/testing/unittest/registar_ut.cpp
@@ -1,7 +1,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
- Y_UNIT_TEST(Assert) {
+Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
+ Y_UNIT_TEST(Assert) {
auto unitAssert = [] {
UNIT_ASSERT(false);
};
@@ -10,7 +10,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT(true);
}
- Y_UNIT_TEST(TypesEqual) {
+ Y_UNIT_TEST(TypesEqual) {
auto typesEqual = [] {
UNIT_ASSERT_TYPES_EQUAL(int, long);
};
@@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_TYPES_EQUAL(TString, TString);
}
- Y_UNIT_TEST(DoublesEqual) {
+ Y_UNIT_TEST(DoublesEqual) {
auto doublesEqual = [](double d1, double d2, double precision) {
UNIT_ASSERT_DOUBLES_EQUAL(d1, d2, precision);
};
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_DOUBLES_EQUAL(nan, nan, 0.1);
}
- Y_UNIT_TEST(StringsEqual) {
+ Y_UNIT_TEST(StringsEqual) {
auto stringsEqual = [](auto s1, auto s2) {
UNIT_ASSERT_STRINGS_EQUAL(s1, s2);
};
@@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_STRINGS_EQUAL("", static_cast<const char*>(nullptr));
}
- Y_UNIT_TEST(StringContains) {
+ Y_UNIT_TEST(StringContains) {
auto stringContains = [](auto s, auto substr) {
UNIT_ASSERT_STRING_CONTAINS(s, substr);
};
@@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_STRING_CONTAINS("lurkmore", "more");
}
- Y_UNIT_TEST(NoDiff) {
+ Y_UNIT_TEST(NoDiff) {
auto noDiff = [](auto s1, auto s2) {
UNIT_ASSERT_NO_DIFF(s1, s2);
};
@@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_NO_DIFF("a", "a");
}
- Y_UNIT_TEST(StringsUnequal) {
+ Y_UNIT_TEST(StringsUnequal) {
auto stringsUnequal = [](auto s1, auto s2) {
UNIT_ASSERT_STRINGS_UNEQUAL(s1, s2);
};
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_STRINGS_UNEQUAL(TStringBuf("C++"), TString("python"));
}
- Y_UNIT_TEST(Equal) {
+ Y_UNIT_TEST(Equal) {
auto equal = [](auto v1, auto v2) {
UNIT_ASSERT_EQUAL(v1, v2);
};
@@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_EQUAL(55, 55);
}
- Y_UNIT_TEST(Unequal) {
+ Y_UNIT_TEST(Unequal) {
auto unequal = [](auto v1, auto v2) {
UNIT_ASSERT_UNEQUAL(v1, v2);
};
@@ -235,7 +235,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_GE(100ul, static_cast<unsigned short>(42));
}
- Y_UNIT_TEST(ValuesEqual) {
+ Y_UNIT_TEST(ValuesEqual) {
auto valuesEqual = [](auto v1, auto v2) {
UNIT_ASSERT_VALUES_EQUAL(v1, v2);
};
@@ -246,7 +246,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_VALUES_EQUAL(1.0, 1.0);
}
- Y_UNIT_TEST(ValuesUnequal) {
+ Y_UNIT_TEST(ValuesUnequal) {
auto valuesUnequal = [](auto v1, auto v2) {
UNIT_ASSERT_VALUES_UNEQUAL(v1, v2);
};
@@ -325,7 +325,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
}
};
- Y_UNIT_TEST(Exception) {
+ Y_UNIT_TEST(Exception) {
UNIT_ASSERT_TEST_FAILS(TTestException("", false).AssertException<TTestException>());
UNIT_ASSERT_TEST_FAILS(TTestException().AssertException<TOtherTestException>());
@@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_EXCEPTION(TTestException().Throw(), TTestException);
}
- Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) {
+ Y_UNIT_TEST(ExceptionAssertionContainsOtherExceptionMessage) {
NUnitTest::TUnitTestFailChecker checker;
{
auto guard = checker.InvokeGuard();
@@ -343,14 +343,14 @@ Y_UNIT_TEST_SUITE(TUnitTestMacroTest) {
UNIT_ASSERT_STRING_CONTAINS(checker.Msg(), "custom exception message");
}
- Y_UNIT_TEST(NoException) {
+ Y_UNIT_TEST(NoException) {
UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoException());
UNIT_ASSERT_TEST_FAILS(TTestException().AssertNoExceptionRet());
UNIT_ASSERT_NO_EXCEPTION(TTestException("", false).Throw());
}
- Y_UNIT_TEST(ExceptionContains) {
+ Y_UNIT_TEST(ExceptionContains) {
UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>("cba"));
UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TStringBuf("cba")));
UNIT_ASSERT_TEST_FAILS(TTestException("abc").AssertExceptionContains<TTestException>(TString("cba")));
diff --git a/library/cpp/testing/unittest/ut/main.cpp b/library/cpp/testing/unittest/ut/main.cpp
index e303e21e30..13c7642dd9 100644
--- a/library/cpp/testing/unittest/ut/main.cpp
+++ b/library/cpp/testing/unittest/ut/main.cpp
@@ -61,25 +61,25 @@ TEST(ETest, Test1) {
UNIT_CHECK_GENERATED_NO_EXCEPTION(true, yexception);
}
-Y_UNIT_TEST_SUITE(TestSingleTestFixture)
+Y_UNIT_TEST_SUITE(TestSingleTestFixture)
{
- Y_UNIT_TEST_F(Test3, TSimpleFixture) {
+ Y_UNIT_TEST_F(Test3, TSimpleFixture) {
UNIT_ASSERT_EQUAL(Value, 24);
}
}
-Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture)
+Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture)
{
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT(Value == 24);
Value = 25;
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
UNIT_ASSERT_EQUAL(Value, 24);
}
- Y_UNIT_TEST_F(Test3, TOtherFixture) {
+ Y_UNIT_TEST_F(Test3, TOtherFixture) {
UNIT_ASSERT_EQUAL(TheAnswer, 42);
}
}
diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp
index 305bc6b40f..09605828a6 100644
--- a/library/cpp/testing/unittest/utmain.cpp
+++ b/library/cpp/testing/unittest/utmain.cpp
@@ -20,7 +20,7 @@
#include <util/network/init.h>
#include <util/stream/file.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/string/join.h>
#include <util/string/util.h>
@@ -502,7 +502,7 @@ private:
ythrow yexception() << "Forked test finished with unknown status";
}
case TShellCommand::SHELL_RUNNING: {
- Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!");
+ Y_VERIFY(false, "This can't happen, we used sync mode, it's a bug!");
}
case TShellCommand::SHELL_INTERNAL_ERROR: {
ythrow yexception() << "Forked test failed with internal error: " << cmd.GetInternalError();
@@ -539,7 +539,7 @@ const char* const TColoredProcessor::ForkCorrectExitMsg = "--END--";
class TEnumeratingProcessor: public ITestSuiteProcessor {
public:
- TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept
+ TEnumeratingProcessor(bool verbose, IOutputStream& stream) noexcept
: Verbose_(verbose)
, Stream_(stream)
{
@@ -564,7 +564,7 @@ public:
private:
bool Verbose_;
- IOutputStream& Stream_;
+ IOutputStream& Stream_;
};
#ifdef _win_
@@ -600,7 +600,7 @@ private:
static const TWinEnvironment Instance;
#endif // _win_
-static int DoList(bool verbose, IOutputStream& stream) {
+static int DoList(bool verbose, IOutputStream& stream) {
TEnumeratingProcessor eproc(verbose, stream);
TTestFactory::Instance().SetProcessor(&eproc);
TTestFactory::Instance().Execute();
@@ -665,8 +665,8 @@ int NUnitTest::RunMain(int argc, char** argv) {
Y_DEFER { NPlugin::OnStopMain(argc, argv); };
TColoredProcessor processor(GetExecPath());
- IOutputStream* listStream = &Cout;
- THolder<IOutputStream> listFile;
+ IOutputStream* listStream = &Cout;
+ THolder<IOutputStream> listFile;
enum EListType {
DONT_LIST,