diff options
author | Josh Gao <jmgao@google.com> | 2018-08-27 16:34:01 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2018-08-27 16:55:07 -0700 |
commit | bf06a40a0d8e61f2926bca9a645126fe46990051 (patch) | |
tree | ad16c54f98e2e101062264b78fbc7a16d1fdbda6 /debuggerd/debuggerd_test.cpp | |
parent | 4843c186340585eaf20610d2538f85234cc63174 (diff) |
debuggerd_test: add test for fdsan abort message.
Bug: http://b/112770187
Test: debuggerd_test
Test: bionic-unit-tests
Change-Id: Ia93761e89074aea4629b8d0f232c580d6f0f249c
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index dfb7a6a7c..e2ea480e5 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -29,6 +29,7 @@ #include <regex> #include <thread> +#include <android/fdsan.h> #include <android/set_abort_message.h> #include <android-base/file.h> @@ -801,6 +802,31 @@ TEST_F(CrasherTest, competing_tracer) { AssertDeath(SIGABRT); } +TEST_F(CrasherTest, fdsan_warning_abort_message) { + int intercept_result; + unique_fd output_fd; + + StartProcess([]() { + android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE); + unique_fd fd(open("/dev/null", O_RDONLY | O_CLOEXEC)); + if (fd == -1) { + abort(); + } + close(fd.get()); + _exit(0); + }); + + StartIntercept(&output_fd); + FinishCrasher(); + AssertDeath(0); + FinishIntercept(&intercept_result); + ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; + + std::string result; + ConsumeFd(std::move(output_fd), &result); + ASSERT_MATCH(result, "Abort message: 'attempted to close"); +} + TEST(crash_dump, zombie) { pid_t forkpid = fork(); |