summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/concurrency.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/concurrency.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/concurrency.cc')
-rw-r--r--test/syscalls/linux/concurrency.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/syscalls/linux/concurrency.cc b/test/syscalls/linux/concurrency.cc
index 2c13b315c..f5a941ca8 100644
--- a/test/syscalls/linux/concurrency.cc
+++ b/test/syscalls/linux/concurrency.cc
@@ -72,8 +72,7 @@ TEST(ConcurrencyTest, MultiProcessMultithreaded) {
}
});
- pid_t child_pid;
- ASSERT_THAT(child_pid = fork(), SyscallSucceeds());
+ pid_t child_pid = fork();
if (child_pid == 0) {
// Busy wait without making any blocking syscalls.
auto end = absl::Now() + absl::Seconds(5);
@@ -81,6 +80,7 @@ TEST(ConcurrencyTest, MultiProcessMultithreaded) {
}
_exit(0);
}
+ ASSERT_THAT(child_pid, SyscallSucceeds());
absl::SleepFor(absl::Seconds(1));
@@ -99,13 +99,13 @@ TEST(ConcurrencyTest, MultiProcessMultithreaded) {
// never yields.
TEST(ConcurrencyTest, MultiProcessConcurrency) {
- pid_t child_pid;
- ASSERT_THAT(child_pid = fork(), SyscallSucceeds());
+ pid_t child_pid = fork();
if (child_pid == 0) {
while (true) {
}
__builtin_unreachable();
}
+ ASSERT_THAT(child_pid, SyscallSucceeds());
absl::SleepFor(absl::Seconds(5));