aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/shellcommand_ut.cpp
diff options
context:
space:
mode:
authorjimmy <jimmy@yandex-team.ru>2022-02-10 16:49:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:38 +0300
commitaffdafdb1fc09bf0bfc384355143ee6db9e90046 (patch)
treeda80bda4720043db2e41dfd1c7fd04de32021fd3 /util/system/shellcommand_ut.cpp
parent4e4faf8d95a4916a49f6674f3ff50e13799fbaa6 (diff)
downloadydb-affdafdb1fc09bf0bfc384355143ee6db9e90046.tar.gz
Restoring authorship annotation for <jimmy@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/shellcommand_ut.cpp')
-rw-r--r--util/system/shellcommand_ut.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/util/system/shellcommand_ut.cpp b/util/system/shellcommand_ut.cpp
index 9d849279d2..5df3277fae 100644
--- a/util/system/shellcommand_ut.cpp
+++ b/util/system/shellcommand_ut.cpp
@@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
options.SetAsync(true);
options.SetQuoteArguments(false);
options.SetLatency(10);
- options.SetClearSignalMask(true);
+ options.SetClearSignalMask(true);
options.SetCloseAllFdsOnExec(true);
options.SetCloseInput(false);
TGuardedStringStream write;
@@ -308,66 +308,66 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
cmd.Run();
sleep(1);
UNIT_ASSERT(TShellCommand::SHELL_RUNNING == cmd.GetStatus());
- // Async mode requires Terminate() + Wait() to send kill to child proc!
- cmd.Terminate();
- cmd.Wait();
- UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
+ // Async mode requires Terminate() + Wait() to send kill to child proc!
+ cmd.Terminate();
+ cmd.Wait();
+ UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
UNIT_ASSERT(cmd.GetExitCode().Defined() && -15 == cmd.GetExitCode());
}
sleep(1);
UNIT_ASSERT(!NFs::Exists(tmpfile));
}
- // this ut is unix-only (win has no signal mask)
+ // this ut is unix-only (win has no signal mask)
Y_UNIT_TEST(TestSignalMask) {
- // block SIGTERM
- int rc;
- sigset_t newmask, oldmask;
- SigEmptySet(&newmask);
- SigAddSet(&newmask, SIGTERM);
- rc = SigProcMask(SIG_SETMASK, &newmask, &oldmask);
- UNIT_ASSERT(rc == 0);
-
+ // block SIGTERM
+ int rc;
+ sigset_t newmask, oldmask;
+ SigEmptySet(&newmask);
+ SigAddSet(&newmask, SIGTERM);
+ rc = SigProcMask(SIG_SETMASK, &newmask, &oldmask);
+ UNIT_ASSERT(rc == 0);
+
TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
-
- TShellCommandOptions options;
- options.SetAsync(true);
- options.SetQuoteArguments(false);
-
- // child proc should not receive SIGTERM anymore
- {
- TShellCommand cmd("/bin/sleep", options);
- // touch file only if sleep not interrupted by SIGTERM
+
+ TShellCommandOptions options;
+ options.SetAsync(true);
+ options.SetQuoteArguments(false);
+
+ // child proc should not receive SIGTERM anymore
+ {
+ TShellCommand cmd("/bin/sleep", options);
+ // touch file only if sleep not interrupted by SIGTERM
cmd << " 10 & wait; [ $? == 0 ] || /usr/bin/touch " << tmpfile;
- cmd.Run();
- sleep(1);
- UNIT_ASSERT(TShellCommand::SHELL_RUNNING == cmd.GetStatus());
- cmd.Terminate();
- cmd.Wait();
+ cmd.Run();
+ sleep(1);
+ UNIT_ASSERT(TShellCommand::SHELL_RUNNING == cmd.GetStatus());
+ cmd.Terminate();
+ cmd.Wait();
UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus() || TShellCommand::SHELL_FINISHED == cmd.GetStatus());
- }
- sleep(1);
+ }
+ sleep(1);
UNIT_ASSERT(!NFs::Exists(tmpfile));
-
- // child proc should receive SIGTERM
- options.SetClearSignalMask(true);
- {
- TShellCommand cmd("/bin/sleep", options);
- // touch file regardless -- it will be interrupted
+
+ // child proc should receive SIGTERM
+ options.SetClearSignalMask(true);
+ {
+ TShellCommand cmd("/bin/sleep", options);
+ // touch file regardless -- it will be interrupted
cmd << " 10 & wait; /usr/bin/touch " << tmpfile;
- cmd.Run();
- sleep(1);
- UNIT_ASSERT(TShellCommand::SHELL_RUNNING == cmd.GetStatus());
- cmd.Terminate();
- cmd.Wait();
- UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
- }
- sleep(1);
+ cmd.Run();
+ sleep(1);
+ UNIT_ASSERT(TShellCommand::SHELL_RUNNING == cmd.GetStatus());
+ cmd.Terminate();
+ cmd.Wait();
+ UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
+ }
+ sleep(1);
UNIT_ASSERT(!NFs::Exists(tmpfile));
-
- // restore signal mask
+
+ // restore signal mask
rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr);
- UNIT_ASSERT(rc == 0);
- }
+ UNIT_ASSERT(rc == 0);
+ }
#else
// This ut is windows-only
Y_UNIT_TEST(TestStdinProperlyConstructed) {