aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/thread_ut.cpp
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 /util/system/thread_ut.cpp
parent30d1ef3941e0dc835be7609de5ebee66958f215a (diff)
downloadydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/thread_ut.cpp')
-rw-r--r--util/system/thread_ut.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp
index d820898fd5..d47c409765 100644
--- a/util/system/thread_ut.cpp
+++ b/util/system/thread_ut.cpp
@@ -4,10 +4,10 @@
#include <atomic>
-Y_UNIT_TEST_SUITE(TSysThreadTest) {
+Y_UNIT_TEST_SUITE(TSysThreadTest) {
struct TIdTester {
inline TIdTester()
- : Thr(nullptr)
+ : Thr(nullptr)
, Cur(0)
, Real(0)
{
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
static inline void* DoRun(void* ptr) {
((TIdTester*)ptr)->Run();
- return nullptr;
+ return nullptr;
}
inline void Run() {
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
TThread::TId Numeric;
};
- Y_UNIT_TEST(TestThreadId) {
+ Y_UNIT_TEST(TestThreadId) {
TIdTester tst;
TThread thr(tst.DoRun, &tst);
@@ -48,131 +48,131 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
void* ThreadProc(void*) {
TThread::SetCurrentThreadName("CurrentThreadSetNameTest");
- return nullptr;
+ return nullptr;
}
void* ThreadProc2(void*) {
- return nullptr;
+ return nullptr;
}
- void* ThreadProc3(void*) {
+ void* ThreadProc3(void*) {
const auto name = TThread::CurrentThreadName();
- Y_FAKE_READ(name);
- return nullptr;
- }
-
- void* ThreadProc4(void*) {
- const TString setName = "ThreadName";
+ Y_FAKE_READ(name);
+ return nullptr;
+ }
+
+ void* ThreadProc4(void*) {
+ const TString setName = "ThreadName";
TThread::SetCurrentThreadName(setName.data());
-
+
const auto getName = TThread::CurrentThreadName();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_VALUES_EQUAL(setName, getName);
} else {
UNIT_ASSERT_VALUES_EQUAL("", getName);
}
- return nullptr;
- }
-
- void* ThreadProcChild(void*) {
+ return nullptr;
+ }
+
+ void* ThreadProcChild(void*) {
const auto name = TThread::CurrentThreadName();
- const auto defaultName = GetProgramName();
-
- (void)name;
- (void)defaultName;
-
-#if defined(_darwin_) || defined(_linux_)
- UNIT_ASSERT_VALUES_EQUAL(name, defaultName);
-#endif
- return nullptr;
- }
-
- void* ThreadProcParent(void*) {
- const TString setName = "Parent";
+ const auto defaultName = GetProgramName();
+
+ (void)name;
+ (void)defaultName;
+
+#if defined(_darwin_) || defined(_linux_)
+ UNIT_ASSERT_VALUES_EQUAL(name, defaultName);
+#endif
+ return nullptr;
+ }
+
+ void* ThreadProcParent(void*) {
+ const TString setName = "Parent";
TThread::SetCurrentThreadName(setName.data());
-
- TThread thread(&ThreadProcChild, nullptr);
-
- thread.Start();
- thread.Join();
-
+
+ TThread thread(&ThreadProcChild, nullptr);
+
+ thread.Start();
+ thread.Join();
+
const auto getName = TThread::CurrentThreadName();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_VALUES_EQUAL(setName, getName);
} else {
UNIT_ASSERT_VALUES_EQUAL("", getName);
}
- return nullptr;
- }
-
- Y_UNIT_TEST(TestSetThreadName) {
- TThread thread(&ThreadProc, nullptr);
+ return nullptr;
+ }
+
+ Y_UNIT_TEST(TestSetThreadName) {
+ TThread thread(&ThreadProc, nullptr);
// just check it doesn't crash
thread.Start();
thread.Join();
}
- Y_UNIT_TEST(TestSetThreadName2) {
- TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX"));
-
- thread.Start();
- thread.Join();
- }
-
- Y_UNIT_TEST(TestGetThreadName) {
- TThread thread(&ThreadProc3, nullptr);
- thread.Start();
- thread.Join();
- }
-
- Y_UNIT_TEST(TestSetGetThreadName) {
- TThread thread(&ThreadProc4, nullptr);
- thread.Start();
- thread.Join();
- }
+ Y_UNIT_TEST(TestSetThreadName2) {
+ TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX"));
- Y_UNIT_TEST(TestSetGetThreadNameInChildThread) {
- TThread thread(&ThreadProcParent, nullptr);
thread.Start();
thread.Join();
}
- Y_UNIT_TEST(TestDoubleJoin) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestGetThreadName) {
+ TThread thread(&ThreadProc3, nullptr);
+ thread.Start();
+ thread.Join();
+ }
+
+ Y_UNIT_TEST(TestSetGetThreadName) {
+ TThread thread(&ThreadProc4, nullptr);
+ thread.Start();
+ thread.Join();
+ }
+
+ Y_UNIT_TEST(TestSetGetThreadNameInChildThread) {
+ TThread thread(&ThreadProcParent, nullptr);
+ thread.Start();
+ thread.Join();
+ }
+
+ Y_UNIT_TEST(TestDoubleJoin) {
+ TThread thread(&ThreadProc, nullptr);
thread.Start();
thread.Join();
- UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
}
- Y_UNIT_TEST(TestDoubleStart) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestDoubleStart) {
+ TThread thread(&ThreadProc, nullptr);
thread.Start();
UNIT_ASSERT_EXCEPTION(thread.Start(), yexception);
thread.Join();
}
- Y_UNIT_TEST(TestNoStart) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestNoStart) {
+ TThread thread(&ThreadProc, nullptr);
}
- Y_UNIT_TEST(TestNoStartJoin) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestNoStartJoin) {
+ TThread thread(&ThreadProc, nullptr);
- UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
}
- Y_UNIT_TEST(TestStackPointer) {
+ Y_UNIT_TEST(TestStackPointer) {
TArrayHolder<char> buf(new char[64000]);
- TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000));
+ TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000));
thr.Start();
UNIT_ASSERT_VALUES_EQUAL(thr.Join(), nullptr);
}
- Y_UNIT_TEST(TestStackLimits) {
+ Y_UNIT_TEST(TestStackLimits) {
TCurrentThreadLimits sl;
UNIT_ASSERT(sl.StackBegin);