aboutsummaryrefslogtreecommitdiff
path: root/tests/fdsan_test.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2020-05-07 19:40:14 -0700
committerJosh Gao <jmgao@google.com>2020-05-07 20:18:40 -0700
commit65fb2a7f0304fda4463771ae40f8b83728e74a62 (patch)
tree2b3a11bb6360757e2cb8d8c8be9bc151e7664728 /tests/fdsan_test.cpp
parent230328374018c7ca4e82a47ff4eb91dd2f79a5c3 (diff)
downloadbionic-65fb2a7f0304fda4463771ae40f8b83728e74a62.tar.gz
fdsan: don't do anything when vforked.
Bug: http://b/153926671 Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator Change-Id: Id351a993e396774b68239edfef83d9e81205290b
Diffstat (limited to 'tests/fdsan_test.cpp')
-rw-r--r--tests/fdsan_test.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/fdsan_test.cpp b/tests/fdsan_test.cpp
index fb3f73dc3..134d62117 100644
--- a/tests/fdsan_test.cpp
+++ b/tests/fdsan_test.cpp
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <unistd.h>
#if defined(__BIONIC__)
#include <android/fdsan.h>
@@ -192,3 +193,21 @@ TEST_F(FdsanTest, unique_fd_unowned_close_after_move) {
EXPECT_FDSAN_DEATH(close(fd_moved.get()), "expected to be unowned, actually owned by unique_fd");
#endif
}
+
+TEST_F(FdsanTest, vfork) {
+ android::base::unique_fd fd(open("/dev/null", O_RDONLY));
+
+ pid_t rc = vfork();
+ ASSERT_NE(-1, rc);
+
+ if (rc == 0) {
+ close(fd.get());
+ _exit(0);
+ }
+
+ int status;
+ pid_t wait_result = waitpid(rc, &status, 0);
+ ASSERT_EQ(wait_result, rc);
+ ASSERT_TRUE(WIFEXITED(status));
+ ASSERT_EQ(0, WEXITSTATUS(status));
+}