summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/kill.cc
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2019-01-11 14:47:45 -0800
committerShentubot <shentubot@google.com>2019-01-11 14:49:39 -0800
commitbf65e06c5f00eb41e40dfbb07dda31c6b7ae443e (patch)
tree4265fa80597165f24456e109053636fad637c10f /test/syscalls/linux/kill.cc
parent290bcb6de9c4aeff65bbfa06b8addecdbc51ca88 (diff)
Clean up some uses of fork() in tests.
- Fix a few cases where async-signal-unsafe code is executed in a forked process pre-execve. - Ensure that the return value of fork() is always checked. PiperOrigin-RevId: 228949310 Change-Id: I3096cb7d7394b8d9ab81b0e0245f2060713ef589
Diffstat (limited to 'test/syscalls/linux/kill.cc')
-rw-r--r--test/syscalls/linux/kill.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/syscalls/linux/kill.cc b/test/syscalls/linux/kill.cc
index 18ba8fb16..de50daf0b 100644
--- a/test/syscalls/linux/kill.cc
+++ b/test/syscalls/linux/kill.cc
@@ -70,7 +70,7 @@ TEST(KillTest, CanKillAllPIDs) {
sa.sa_sigaction = SigHandler;
sigfillset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
- auto cleanup = ASSERT_NO_ERRNO_AND_VALUE(ScopedSigaction(SIGWINCH, sa));
+ auto cleanup = ScopedSigaction(SIGWINCH, sa).ValueOrDie();
// Indicate to the parent that we're ready.
write_fd.reset();
@@ -81,7 +81,7 @@ TEST(KillTest, CanKillAllPIDs) {
}
}
- EXPECT_THAT(pid, SyscallSucceeds());
+ ASSERT_THAT(pid, SyscallSucceeds());
write_fd.reset();
@@ -111,7 +111,7 @@ TEST(KillTest, CannotKillInvalidPID) {
_exit(0);
}
- EXPECT_THAT(fake_pid, SyscallSucceeds());
+ ASSERT_THAT(fake_pid, SyscallSucceeds());
int status;
ASSERT_THAT(RetryEINTR(waitpid)(fake_pid, &status, 0),
@@ -134,7 +134,7 @@ TEST(KillTest, CanKillRemoteProcess) {
}
}
- EXPECT_THAT(pid, SyscallSucceeds());
+ ASSERT_THAT(pid, SyscallSucceeds());
EXPECT_THAT(kill(pid, SIGKILL), SyscallSucceeds());
@@ -182,7 +182,7 @@ TEST(KillTest, SetPgid) {
}
}
- EXPECT_THAT(pid, SyscallSucceeds());
+ ASSERT_THAT(pid, SyscallSucceeds());
// Set the child's group and exit.
ASSERT_THAT(setpgid(pid, pid), SyscallSucceeds());
@@ -208,7 +208,7 @@ TEST(KillTest, ProcessGroups) {
pause();
}
}
- EXPECT_THAT(child, SyscallSucceeds());
+ ASSERT_THAT(child, SyscallSucceeds());
pid_t other_child = fork();
if (other_child == 0) {
@@ -216,6 +216,7 @@ TEST(KillTest, ProcessGroups) {
pause();
}
}
+ ASSERT_THAT(other_child, SyscallSucceeds());
// Ensure the kill does not succeed without the new group.
EXPECT_THAT(kill(-child, SIGKILL), SyscallFailsWithErrno(ESRCH));
@@ -298,7 +299,7 @@ TEST(KillTest, ChildDropsPrivsCannotKill) {
_exit(0);
}
- EXPECT_THAT(pid, SyscallSucceeds());
+ ASSERT_THAT(pid, SyscallSucceeds());
int status;
EXPECT_THAT(RetryEINTR(waitpid)(pid, &status, 0),
@@ -316,7 +317,7 @@ TEST(KillTest, CanSIGCONTSameSession) {
_exit(0);
}
- EXPECT_THAT(stopped_child, SyscallSucceeds());
+ ASSERT_THAT(stopped_child, SyscallSucceeds());
// Put the child in its own process group. The child and parent process
// groups also share a session.
@@ -359,7 +360,7 @@ TEST(KillTest, CanSIGCONTSameSession) {
_exit(0);
}
- EXPECT_THAT(stopped_child, SyscallSucceeds());
+ ASSERT_THAT(stopped_child, SyscallSucceeds());
// Make sure child exited normally.
EXPECT_THAT(RetryEINTR(waitpid)(stopped_child, &status, 0),