summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_report_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-07-07 13:53:33 -0700
committerYabin Cui <yabinc@google.com>2016-07-07 14:11:14 -0700
commiteec606cfefcb8cb20ac0f9e3465daff09fb31ffd (patch)
treef89dc7b7cd94e329639023f4f49f1e2f65578517 /simpleperf/cmd_report_test.cpp
parent13a21e1df32f6227e61e22062d79ed4c42198ff2 (diff)
downloadextras-eec606cfefcb8cb20ac0f9e3465daff09fb31ffd.tar.gz
simpleperf: fix build id check of files in symfs.
In dso.cpp, build_id_map_ should use path_ instead of GetAccessiblePath() as the key. However, patch https://android-review.googlesource.com/#/c/175654/ wrongly used GetAccessiblePath() as the key in build_id_map_. This patch fixes the error and add corresponding test. Check if file in symfs exists before using it as debug file path. If the build id of debug file path doesn't match the one in build_id_map_, output warning to user. Bug: 28911532 Test: run simpleperf_unit_test. Change-Id: I21bca508359a492245db4cba5d287005363cd465
Diffstat (limited to 'simpleperf/cmd_report_test.cpp')
-rw-r--r--simpleperf/cmd_report_test.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index 14f44639..48fe0df7 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -317,6 +317,26 @@ TEST_F(ReportCommandTest, report_sort_vaddr_in_file) {
ASSERT_NE(content.find("VaddrInFile"), std::string::npos);
}
+TEST_F(ReportCommandTest, check_build_id) {
+ Report(PERF_DATA_FOR_BUILD_ID_CHECK,
+ {"--symfs", GetTestData(CORRECT_SYMFS_FOR_BUILD_ID_CHECK)});
+ ASSERT_TRUE(success);
+ ASSERT_NE(content.find("main"), std::string::npos);
+ ASSERT_EXIT(
+ {
+ Report(PERF_DATA_FOR_BUILD_ID_CHECK,
+ {"--symfs", GetTestData(WRONG_SYMFS_FOR_BUILD_ID_CHECK)});
+ if (!success) {
+ exit(1);
+ }
+ if (content.find("main") != std::string::npos) {
+ exit(2);
+ }
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "build id.*mismatch");
+}
+
#if defined(__linux__)
static std::unique_ptr<Command> RecordCmd() {