diff options
author | Josh Gao <jmgao@google.com> | 2020-12-09 14:01:13 -0800 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2021-04-07 19:00:45 -0700 |
commit | dcc97c0887c57844c832f4497866320697811e88 (patch) | |
tree | 6f15dcf66c1b9b4b5e6e6d4b7642f555bf2a6ee6 /tests | |
parent | 87a205eefa2e12597f6d7a05db05fefbe498a292 (diff) |
Disable fdtrack post-fork.
Also delete some fdsan code that attempts to check for the post-fork
state, but never will, because we update the cached pid upon fork.
Bug: http://b/174542867
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Test: treehugger
Change-Id: I9b748dac9de9b4c741897d93e64d31737e52bf8e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fdtrack_test.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/fdtrack_test.cpp b/tests/fdtrack_test.cpp index 13f1b2e18..9fcb40283 100644 --- a/tests/fdtrack_test.cpp +++ b/tests/fdtrack_test.cpp @@ -57,8 +57,13 @@ void DumpEvent(std::vector<android_fdtrack_event>* events, size_t index) { } } -std::vector<android_fdtrack_event> FdtrackRun(void (*func)()) { +std::vector<android_fdtrack_event> FdtrackRun(void (*func)(), bool reenable = true) { // Each bionic test is run in separate process, so we can safely use a static here. + // However, since they're all forked, we need to reenable fdtrack. + if (reenable) { + android_fdtrack_set_globally_enabled(true); + } + static std::vector<android_fdtrack_event> events; events.clear(); @@ -129,6 +134,21 @@ TEST(fdtrack, close) { #endif } +TEST(fdtrack, fork) { +#if defined(__BIONIC__) + ASSERT_EXIT( + []() { + static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC); + ASSERT_NE(-1, fd); + + auto events = FdtrackRun([]() { close(fd); }, false); + ASSERT_EQ(0U, events.size()); + exit(0); + }(), + testing::ExitedWithCode(0), ""); +#endif +} + TEST(fdtrack, enable_disable) { #if defined(__BIONIC__) static int fd1 = -1; |