summaryrefslogtreecommitdiffhomepage
path: root/test/util/multiprocess_util.cc
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2021-01-22 18:04:14 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-22 18:06:09 -0800
commitcac70c65e6b5b8a7a3eda55f83f9ceffdfdaba89 (patch)
treeba8618a1576cb6f519ecfcb0ab4eea4ec3230fdf /test/util/multiprocess_util.cc
parent99aa5eedcfa3f2e458171cbc6b20ee6f78af3229 (diff)
Detect failures in forked function
EXPECT*/ASSERT* functions are not async-signal-safe and should not be called from the function passed to InForkedProcess. However, these happen accidentally sometimes but do no cause InForkedProcess to fail. Detect and notify in such cases. PiperOrigin-RevId: 353354540
Diffstat (limited to 'test/util/multiprocess_util.cc')
-rw-r--r--test/util/multiprocess_util.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/util/multiprocess_util.cc b/test/util/multiprocess_util.cc
index 8b676751b..a6b0de24b 100644
--- a/test/util/multiprocess_util.cc
+++ b/test/util/multiprocess_util.cc
@@ -154,6 +154,9 @@ PosixErrorOr<int> InForkedProcess(const std::function<void()>& fn) {
pid_t pid = fork();
if (pid == 0) {
fn();
+ TEST_CHECK_MSG(!::testing::Test::HasFailure(),
+ "EXPECT*/ASSERT* failed. These are not async-signal-safe "
+ "and must not be called from fn.");
_exit(0);
}
MaybeSave();