diff options
author | akhropov <akhropov@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
commit | 00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch) | |
tree | cb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /util/system/interrupt_signals_ut.cpp | |
parent | 83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff) | |
download | ydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz |
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/interrupt_signals_ut.cpp')
-rw-r--r-- | util/system/interrupt_signals_ut.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/util/system/interrupt_signals_ut.cpp b/util/system/interrupt_signals_ut.cpp index bec54fec61..822c290e82 100644 --- a/util/system/interrupt_signals_ut.cpp +++ b/util/system/interrupt_signals_ut.cpp @@ -1,46 +1,46 @@ -#include "interrupt_signals.h" - -#include "atomic.h" - -#include <util/datetime/base.h> - +#include "interrupt_signals.h" + +#include "atomic.h" + +#include <util/datetime/base.h> + #include <library/cpp/testing/unittest/registar.h> - -#ifdef _win_ - #include <windows.h> -#endif - + +#ifdef _win_ + #include <windows.h> +#endif + Y_UNIT_TEST_SUITE(TTestInterruptSignals) { - static TAtomic HandledSigNum = 0; - - static void Handler(int signum) { - AtomicSet(HandledSigNum, signum); - } - + static TAtomic HandledSigNum = 0; + + static void Handler(int signum) { + AtomicSet(HandledSigNum, signum); + } + Y_UNIT_TEST(Test1) { - SetInterruptSignalsHandler(Handler); -#ifdef _win_ - // TODO: unfortunately GenerateConsoleCtrlEvent fails under Wine - /* - for (auto [winEvent, posixSigNum] : { - std::make_pair(CTRL_C_EVENT, SIGINT), - std::make_pair(CTRL_BREAK_EVENT, SIGTERM) - }) - { - if (!GenerateConsoleCtrlEvent(winEvent, 0)) { - UNIT_FAIL("GenerateConsoleCtrlEvent failed: " << LastSystemErrorText()); - } - Sleep(TDuration::MilliSeconds(100)); - UNIT_ASSERT_VALUES_EQUAL(HandledSigNum, posixSigNum); - } - */ - for (int signum : {SIGINT, SIGTERM}) { -#else - for (int signum : {SIGINT, SIGTERM, SIGHUP}) { -#endif - std::raise(signum); - Sleep(TDuration::MilliSeconds(100)); // give it time to handle an async signal - UNIT_ASSERT_VALUES_EQUAL(HandledSigNum, signum); - } - } -} + SetInterruptSignalsHandler(Handler); +#ifdef _win_ + // TODO: unfortunately GenerateConsoleCtrlEvent fails under Wine + /* + for (auto [winEvent, posixSigNum] : { + std::make_pair(CTRL_C_EVENT, SIGINT), + std::make_pair(CTRL_BREAK_EVENT, SIGTERM) + }) + { + if (!GenerateConsoleCtrlEvent(winEvent, 0)) { + UNIT_FAIL("GenerateConsoleCtrlEvent failed: " << LastSystemErrorText()); + } + Sleep(TDuration::MilliSeconds(100)); + UNIT_ASSERT_VALUES_EQUAL(HandledSigNum, posixSigNum); + } + */ + for (int signum : {SIGINT, SIGTERM}) { +#else + for (int signum : {SIGINT, SIGTERM, SIGHUP}) { +#endif + std::raise(signum); + Sleep(TDuration::MilliSeconds(100)); // give it time to handle an async signal + UNIT_ASSERT_VALUES_EQUAL(HandledSigNum, signum); + } + } +} |