diff options
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index abce0569f..ab95768de 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <dirent.h> #include <err.h> #include <fcntl.h> #include <malloc.h> @@ -311,7 +312,7 @@ TEST_F(CrasherTest, smoke) { if (mte_supported()) { // Test that the default TAGGED_ADDR_CTRL value is set. - ASSERT_MATCH(result, R"(tagged_addr_ctrl: 000000000007fff5)"); + ASSERT_MATCH(result, R"(tagged_addr_ctrl: 000000000007fff3)"); } } @@ -373,11 +374,11 @@ TEST_F(CrasherTest, heap_addr_in_register) { ConsumeFd(std::move(output_fd), &result); #if defined(__aarch64__) - ASSERT_MATCH(result, "memory near x0"); + ASSERT_MATCH(result, "memory near x0 \\(\\[anon:"); #elif defined(__arm__) - ASSERT_MATCH(result, "memory near r0"); + ASSERT_MATCH(result, "memory near r0 \\(\\[anon:"); #elif defined(__x86_64__) - ASSERT_MATCH(result, "memory near rdi"); + ASSERT_MATCH(result, "memory near rdi \\(\\[anon:"); #else ASSERT_TRUE(false) << "unsupported architecture"; #endif @@ -1451,9 +1452,16 @@ TEST(tombstoned, proto) { std::this_thread::sleep_for(100ms); // Find the tombstone. - std::optional<int> tombstone_index; - for (int i = 0; i < 50; ++i) { - std::string path = android::base::StringPrintf("/data/tombstones/tombstone_%02d", i); + std::optional<std::string> tombstone_file; + std::unique_ptr<DIR, decltype(&closedir)> dir_h(opendir("/data/tombstones"), closedir); + ASSERT_TRUE(dir_h != nullptr); + std::regex tombstone_re("tombstone_\\d+"); + dirent* entry; + while ((entry = readdir(dir_h.get())) != nullptr) { + if (!std::regex_match(entry->d_name, tombstone_re)) { + continue; + } + std::string path = android::base::StringPrintf("/data/tombstones/%s", entry->d_name); struct stat st; if (TEMP_FAILURE_RETRY(stat(path.c_str(), &st)) != 0) { @@ -1461,14 +1469,13 @@ TEST(tombstoned, proto) { } if (st.st_dev == text_st.st_dev && st.st_ino == text_st.st_ino) { - tombstone_index = i; + tombstone_file = path; break; } } - ASSERT_TRUE(tombstone_index); - std::string proto_path = - android::base::StringPrintf("/data/tombstones/tombstone_%02d.pb", *tombstone_index); + ASSERT_TRUE(tombstone_file); + std::string proto_path = tombstone_file.value() + ".pb"; struct stat proto_fd_st; struct stat proto_file_st; |