diff options
author | Yabin Cui <yabinc@google.com> | 2023-11-13 20:59:17 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-11-13 20:59:17 +0000 |
commit | d59010441b866ec457a75be58ce3871da7e8b0b9 (patch) | |
tree | 4dc4c9c593ba634835e812aa09075f1260e0d392 | |
parent | c09cef115ef62b655c39f5c87d6b78ba92a9765b (diff) | |
parent | 3621c90318995afd77d60dab7a7567ca39cf62dc (diff) | |
download | extras-d59010441b866ec457a75be58ce3871da7e8b0b9.tar.gz |
Merge "simpleperf: Fix flaky test check_trampoline_after_art_jni_methods" into main
-rw-r--r-- | simpleperf/cmd_record_test.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 5be7b165..d969dc60 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -34,6 +34,7 @@ #include <android-base/test_utils.h> #include "ETMRecorder.h" +#include "JITDebugReader.h" #include "ProbeEvents.h" #include "cmd_record_impl.h" #include "command.h" @@ -929,10 +930,23 @@ TEST(record_cmd, check_trampoline_after_art_jni_methods) { if (android::base::StartsWith(sym_name, "art::Method_invoke") && i + 1 < ips.size()) { has_check = true; std::string name = get_symbol_name(thread, ips[i + 1]); - if (!android::base::EndsWith(name, "jni_trampoline")) { - GTEST_LOG_(ERROR) << "unexpected symbol after art::Method_invoke: " << name; - return false; + if (android::base::EndsWith(name, "jni_trampoline")) { + continue; } + // When the jni_trampoline function is from JIT cache, we may not get map info in time. + // To avoid test flakiness, we accept this. + // Case 1: It doesn't hit any maps. + if (name == "unknown") { + continue; + } + // Case 2: It hits an old map for JIT cache. + if (const MapEntry* map = thread_tree.FindMap(thread, ips[i + 1], false); + JITDebugReader::IsPathInJITSymFile(map->dso->Path())) { + continue; + } + + GTEST_LOG_(ERROR) << "unexpected symbol after art::Method_invoke: " << name; + return false; } } } |