diff options
Diffstat (limited to 'simpleperf/cmd_report_test.cpp')
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp index 6dfbae5c..9170beb2 100644 --- a/simpleperf/cmd_report_test.cpp +++ b/simpleperf/cmd_report_test.cpp @@ -37,19 +37,27 @@ static std::unique_ptr<Command> ReportCmd() { return CreateCommandInstance("report"); } +// @CddTest = 6.1/C-0-2 class ReportCommandTest : public ::testing::Test { protected: void Report(const std::string& perf_data, - const std::vector<std::string>& add_args = std::vector<std::string>()) { - ReportRaw(GetTestData(perf_data), add_args); + const std::vector<std::string>& add_args = std::vector<std::string>(), + bool with_symfs = true) { + ReportRaw(GetTestData(perf_data), add_args, with_symfs); } void ReportRaw(const std::string& perf_data, - const std::vector<std::string>& add_args = std::vector<std::string>()) { + const std::vector<std::string>& add_args = std::vector<std::string>(), + bool with_symfs = true) { success = false; TemporaryFile tmp_file; - std::vector<std::string> args = {"-i", perf_data, "--symfs", GetTestDataDir(), - "-o", tmp_file.path}; + std::vector<std::string> args = {"-i", perf_data, "-o", tmp_file.path}; + + if (with_symfs) { + args.emplace_back("--symfs"); + args.emplace_back(GetTestDataDir()); + } + args.insert(args.end(), add_args.begin(), add_args.end()); ASSERT_TRUE(ReportCmd()->Run(args)); ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &content)); @@ -83,18 +91,21 @@ class ReportCommandTest : public ::testing::Test { bool success; }; +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, no_option) { Report(PERF_DATA); ASSERT_TRUE(success); ASSERT_NE(content.find("GlobalFunc"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_symbol_from_elf_file_with_mini_debug_info) { Report(PERF_DATA_WITH_MINI_DEBUG_INFO); ASSERT_TRUE(success); ASSERT_NE(content.find("GlobalFunc"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, sort_option_pid) { Report(PERF_DATA, {"--sort", "pid"}); ASSERT_TRUE(success); @@ -105,6 +116,7 @@ TEST_F(ReportCommandTest, sort_option_pid) { ASSERT_LT(line_index + 2, lines.size()); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, sort_option_more_than_one) { Report(PERF_DATA, {"--sort", "comm,pid,dso,symbol"}); ASSERT_TRUE(success); @@ -120,6 +132,7 @@ TEST_F(ReportCommandTest, sort_option_more_than_one) { ASSERT_EQ(lines[line_index].find("Tid"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, children_option) { Report(CALLGRAPH_FP_PERF_DATA, {"--children", "--sort", "symbol"}); ASSERT_TRUE(success); @@ -164,6 +177,7 @@ static bool CheckCallerMode(std::vector<std::string>& lines) { return found; } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, callgraph_option) { Report(CALLGRAPH_FP_PERF_DATA, {"-g"}); ASSERT_TRUE(success); @@ -201,6 +215,7 @@ static bool AllItemsWithString(std::vector<std::string>& lines, return true; } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, pid_filter_option) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "pid"}); ASSERT_TRUE(success); @@ -221,6 +236,7 @@ TEST_F(ReportCommandTest, pid_filter_option) { ASSERT_NE(content.find("17445"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, wrong_pid_filter_option) { ASSERT_EXIT( { @@ -230,6 +246,7 @@ TEST_F(ReportCommandTest, wrong_pid_filter_option) { testing::ExitedWithCode(1), "invalid pid: bogus"); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, tid_filter_option) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "tid"}); ASSERT_TRUE(success); @@ -243,6 +260,7 @@ TEST_F(ReportCommandTest, tid_filter_option) { ASSERT_TRUE(AllItemsWithString(lines, {"17441", "17445"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, wrong_tid_filter_option) { ASSERT_EXIT( { @@ -252,6 +270,7 @@ TEST_F(ReportCommandTest, wrong_tid_filter_option) { testing::ExitedWithCode(1), "Invalid tid 'bogus'"); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, comm_filter_option) { Report(PERF_DATA, {"--sort", "comm"}); ASSERT_TRUE(success); @@ -265,6 +284,7 @@ TEST_F(ReportCommandTest, comm_filter_option) { ASSERT_TRUE(AllItemsWithString(lines, {"t1", "t2"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, dso_filter_option) { Report(PERF_DATA, {"--sort", "dso"}); ASSERT_TRUE(success); @@ -278,6 +298,7 @@ TEST_F(ReportCommandTest, dso_filter_option) { ASSERT_TRUE(AllItemsWithString(lines, {"/t1", "/t2"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, symbol_filter_option) { Report(PERF_DATA_WITH_SYMBOLS, {"--sort", "symbol"}); ASSERT_TRUE(success); @@ -291,6 +312,7 @@ TEST_F(ReportCommandTest, symbol_filter_option) { ASSERT_TRUE(AllItemsWithString(lines, {"main", "func2(int, int)"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, dso_symbol_filter_with_children_option) { // dso and symbol filter should filter different layers of the callchain separately. Report("perf_display_bitmaps.data", {"--dsos", "/apex/com.android.runtime/lib64/libart.so", @@ -305,6 +327,7 @@ TEST_F(ReportCommandTest, dso_symbol_filter_with_children_option) { ASSERT_NE(content.find("51500000 2500000 MterpInvokeVirtual"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, use_branch_address) { Report(BRANCH_PERF_DATA, {"-b", "--sort", "symbol_from,symbol_to"}); std::set<std::pair<std::string, std::string>> hit_set; @@ -326,6 +349,7 @@ TEST_F(ReportCommandTest, use_branch_address) { hit_set.end()); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_symbols_of_nativelib_in_apk) { Report(NATIVELIB_IN_APK_PERF_DATA); ASSERT_TRUE(success); @@ -333,6 +357,7 @@ TEST_F(ReportCommandTest, report_symbols_of_nativelib_in_apk) { ASSERT_NE(content.find("Func2"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_more_than_one_event_types) { Report(PERF_DATA_WITH_TWO_EVENT_TYPES); ASSERT_TRUE(success); @@ -343,12 +368,14 @@ TEST_F(ReportCommandTest, report_more_than_one_event_types) { ASSERT_NE(pos = content.find("Samples:", pos), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_kernel_symbol) { Report(PERF_DATA_WITH_KERNEL_SYMBOL); ASSERT_TRUE(success); ASSERT_NE(content.find("perf_event_aux"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_dumped_symbols) { Report(PERF_DATA_WITH_SYMBOLS); ASSERT_TRUE(success); @@ -358,6 +385,7 @@ TEST_F(ReportCommandTest, report_dumped_symbols) { ASSERT_NE(content.find("memcpy"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_dumped_symbols_with_symfs_dir) { // Check if we can report symbols when they appear both in perf.data and symfs dir. Report(PERF_DATA_WITH_SYMBOLS, {"--symfs", GetTestDataDir()}); @@ -365,17 +393,28 @@ TEST_F(ReportCommandTest, report_dumped_symbols_with_symfs_dir) { ASSERT_NE(content.find("main"), std::string::npos); } +// @CddTest = 6.1/C-0-2 +TEST_F(ReportCommandTest, report_dumped_symbols_with_symdir) { + // Check if we can report symbols by specifying symdir. + Report(PERF_DATA, {"--symdir", GetTestDataDir()}, false); + ASSERT_TRUE(success); + ASSERT_NE(content.find("GlobalFunc"), std::string::npos); +} + +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_without_symfs_dir) { TemporaryFile tmpfile; ASSERT_TRUE(ReportCmd()->Run({"-i", GetTestData(PERF_DATA), "-o", tmpfile.path})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_sort_vaddr_in_file) { Report(PERF_DATA, {"--sort", "vaddr_in_file"}); ASSERT_TRUE(success); ASSERT_NE(content.find("VaddrInFile"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, check_build_id) { Report(PERF_DATA_FOR_BUILD_ID_CHECK, {"--symfs", GetTestData(CORRECT_SYMFS_FOR_BUILD_ID_CHECK)}); ASSERT_TRUE(success); @@ -395,6 +434,7 @@ TEST_F(ReportCommandTest, check_build_id) { testing::ExitedWithCode(0), "failed to read symbols from /elf_for_build_id_check"); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, no_show_ip_option) { Report(PERF_DATA); ASSERT_TRUE(success); @@ -404,6 +444,7 @@ TEST_F(ReportCommandTest, no_show_ip_option) { ASSERT_NE(content.find("unknown"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, read_elf_file_warning) { ASSERT_EXIT( { @@ -419,11 +460,13 @@ TEST_F(ReportCommandTest, read_elf_file_warning) { testing::ExitedWithCode(0), "failed to read symbols from /elf: File not found"); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_data_generated_by_linux_perf) { Report(PERF_DATA_GENERATED_BY_LINUX_PERF); ASSERT_TRUE(success); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, max_stack_and_percent_limit_option) { Report(PERF_DATA_MAX_STACK_AND_PERCENT_LIMIT, {"-g"}); ASSERT_TRUE(success); @@ -444,6 +487,7 @@ TEST_F(ReportCommandTest, max_stack_and_percent_limit_option) { ASSERT_NE(content.find("89.03"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, percent_limit_option) { Report(PERF_DATA); ASSERT_TRUE(success); @@ -455,16 +499,19 @@ TEST_F(ReportCommandTest, percent_limit_option) { ASSERT_EQ(content.find("3.23%"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, kallsyms_option) { Report(PERF_DATA, {"--kallsyms", GetTestData("kallsyms")}); ASSERT_TRUE(success); ASSERT_NE(content.find("FakeKernelSymbol"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, invalid_perf_data) { ASSERT_FALSE(ReportCmd()->Run({"-i", GetTestData(INVALID_PERF_DATA)})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, raw_period_option) { Report(PERF_DATA, {"--raw-period"}); ASSERT_TRUE(success); @@ -472,6 +519,7 @@ TEST_F(ReportCommandTest, raw_period_option) { ASSERT_EQ(content.find('%'), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, full_callgraph_option) { Report(CALLGRAPH_FP_PERF_DATA, {"-g"}); ASSERT_TRUE(success); @@ -481,6 +529,7 @@ TEST_F(ReportCommandTest, full_callgraph_option) { ASSERT_EQ(content.find("skipped in brief callgraph mode"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_offcpu_time) { Report(PERF_DATA_WITH_TRACE_OFFCPU, {"--children"}); ASSERT_TRUE(success); @@ -496,11 +545,13 @@ TEST_F(ReportCommandTest, report_offcpu_time) { ASSERT_TRUE(found); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_big_trace_data) { Report(PERF_DATA_WITH_BIG_TRACE_DATA); ASSERT_TRUE(success); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, csv_option) { Report(PERF_DATA, {"--csv"}); ASSERT_TRUE(success); @@ -511,6 +562,7 @@ TEST_F(ReportCommandTest, csv_option) { ASSERT_NE(content.find("AccEventCount,SelfEventCount,EventName"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, csv_separator_option) { Report(PERF_DATA, {"--csv", "--csv-separator", ";"}); ASSERT_TRUE(success); @@ -518,6 +570,7 @@ TEST_F(ReportCommandTest, csv_separator_option) { ASSERT_NE(content.find(";cpu-cycles"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, dso_path_for_jit_cache) { Report("perf_with_jit_symbol.data", {"--sort", "dso"}); ASSERT_TRUE(success); @@ -529,12 +582,14 @@ TEST_F(ReportCommandTest, dso_path_for_jit_cache) { ASSERT_NE(content.find("[JIT app cache]"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, generic_jit_symbols) { Report("perf_with_generic_git_symbols.data", {"--sort", "symbol"}); ASSERT_TRUE(success); ASSERT_NE(std::string::npos, content.find("generic_jit_symbol_one")); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, cpu_option) { Report("perf.data"); ASSERT_TRUE(success); @@ -551,6 +606,7 @@ TEST_F(ReportCommandTest, cpu_option) { ASSERT_FALSE(ReportCmd()->Run({"-i", GetTestData("perf.data"), "--cpu", "-2"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, print_event_count_option) { // Report record file not recorded with --add-counter. Report("perf.data", {"--print-event-count"}); @@ -583,6 +639,7 @@ TEST_F(ReportCommandTest, print_event_count_option) { ->Search(content)); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, exclude_include_pid_options) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "pid", "--exclude-pid", "17441"}); ASSERT_TRUE(success); @@ -592,6 +649,7 @@ TEST_F(ReportCommandTest, exclude_include_pid_options) { ASSERT_TRUE(AllItemsWithString(lines, {"17441"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, exclude_include_tid_options) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "tid", "--exclude-tid", "17441,17443,17444"}); @@ -603,6 +661,7 @@ TEST_F(ReportCommandTest, exclude_include_tid_options) { ASSERT_TRUE(AllItemsWithString(lines, {"17441", "17443", "17444"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, exclude_include_process_name_options) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "comm", "--exclude-process-name", "t1"}); ASSERT_TRUE(success); @@ -612,6 +671,7 @@ TEST_F(ReportCommandTest, exclude_include_process_name_options) { ASSERT_TRUE(AllItemsWithString(lines, {"t1"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, exclude_include_thread_name_options) { Report(PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS, {"--sort", "comm", "--exclude-thread-name", "t1"}); ASSERT_TRUE(success); @@ -621,6 +681,7 @@ TEST_F(ReportCommandTest, exclude_include_thread_name_options) { ASSERT_TRUE(AllItemsWithString(lines, {"t1"})); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, filter_file_option) { std::string filter_data = "GLOBAL_BEGIN 684943449406175\n" @@ -645,6 +706,7 @@ static std::unique_ptr<Command> RecordCmd() { return CreateCommandInstance("record"); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, dwarf_callgraph) { TEST_REQUIRE_HW_COUNTER(); OMIT_TEST_ON_NON_NATIVE_ABIS(); @@ -658,6 +720,7 @@ TEST_F(ReportCommandTest, dwarf_callgraph) { ASSERT_TRUE(success); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, report_dwarf_callgraph_of_nativelib_in_apk) { Report(NATIVELIB_IN_APK_PERF_DATA, {"-g"}); ASSERT_NE(content.find(GetUrlInApk(APK_FILE, NATIVELIB_IN_APK)), std::string::npos); @@ -666,6 +729,7 @@ TEST_F(ReportCommandTest, report_dwarf_callgraph_of_nativelib_in_apk) { ASSERT_NE(content.find("GlobalFunc"), std::string::npos); } +// @CddTest = 6.1/C-0-2 TEST_F(ReportCommandTest, exclude_kernel_callchain) { TEST_REQUIRE_HW_COUNTER(); TEST_REQUIRE_HOST_ROOT(); |