mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
committed by
gVisor bot
parent
99aa5eedcf
commit
cac70c65e6
@@ -172,6 +172,7 @@ cc_library(
|
||||
":posix_error",
|
||||
":save_util",
|
||||
":test_util",
|
||||
gtest,
|
||||
"@com_google_absl//absl/strings",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user