From: Yabin Cui Date: Wed, 13 Sep 2017 20:21:32 +0000 (-0700) Subject: simpleperf: Omit dwarf-callgraph tests running on arm translation tools. X-Git-Tag: android-x86-8.1-r1^2~4^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3035e41eb6d6e6dc89520aada7f74dc874c14a56;hp=98e42725761e4df326851f08a491f553619debdf;p=android-x86%2Fsystem-extras.git simpleperf: Omit dwarf-callgraph tests running on arm translation tools. Bug: http://b/64946809 Bug: 64709603 (presubmit balking at the line above) Test: run arm CtsSimpleperfTestCases32 on fugu. Change-Id: I76ee44b8fd2a6022cbef32392ee0336fe4d14ade (cherry picked from commit 64a9ecda2c006f90dcc047ad95be792139622ead) --- diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 8b70fcd2..c3f9cb40 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -16,6 +16,8 @@ #include +#include +#include #include #include @@ -155,7 +157,31 @@ TEST(record_cmd, system_wide_fp_callchain_sampling) { TEST_IN_ROOT(ASSERT_TRUE(RunRecordCmd({"-a", "--call-graph", "fp"}))); } +bool IsInNativeAbi() { + static int in_native_abi = -1; + if (in_native_abi == -1) { + FILE* fp = popen("uname -m", "re"); + char buf[40]; + memset(buf, '\0', sizeof(buf)); + fgets(buf, sizeof(buf), fp); + pclose(fp); + std::string s = buf; + in_native_abi = 1; + if (GetBuildArch() == ARCH_X86_32 || GetBuildArch() == ARCH_X86_64) { + if (s.find("86") == std::string::npos) { + in_native_abi = 0; + } + } else if (GetBuildArch() == ARCH_ARM || GetBuildArch() == ARCH_ARM64) { + if (s.find("arm") == std::string::npos && s.find("aarch64") == std::string::npos) { + in_native_abi = 0; + } + } + } + return in_native_abi == 1; +} + TEST(record_cmd, dwarf_callchain_sampling) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); std::vector> workloads; CreateProcesses(1, &workloads); @@ -167,17 +193,20 @@ TEST(record_cmd, dwarf_callchain_sampling) { } TEST(record_cmd, system_wide_dwarf_callchain_sampling) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); TEST_IN_ROOT(RunRecordCmd({"-a", "--call-graph", "dwarf"})); } TEST(record_cmd, no_unwind_option) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); ASSERT_TRUE(RunRecordCmd({"--call-graph", "dwarf", "--no-unwind"})); ASSERT_FALSE(RunRecordCmd({"--no-unwind"})); } TEST(record_cmd, post_unwind_option) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); std::vector> workloads; CreateProcesses(1, &workloads); @@ -296,6 +325,7 @@ TEST(record_cmd, no_dump_symbols) { ASSERT_TRUE(RunRecordCmd({"--no-dump-symbols"}, tmpfile.path)); CheckDsoSymbolRecords(tmpfile.path, false, &success); ASSERT_TRUE(success); + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); std::vector> workloads; CreateProcesses(1, &workloads); @@ -431,6 +461,7 @@ TEST(record_cmd, cpu_clock_for_a_long_time) { } TEST(record_cmd, dump_regs_for_tracepoint_events) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); // Check if the kernel can dump registers for tracepoint events. // If not, probably a kernel patch below is missing: // "5b09a094f2 arm64: perf: Fix callchain parse error with kernel tracepoint events" diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp index f1f5b1fc..e146876b 100644 --- a/simpleperf/cmd_report_test.cpp +++ b/simpleperf/cmd_report_test.cpp @@ -479,6 +479,7 @@ static std::unique_ptr RecordCmd() { } TEST_F(ReportCommandTest, dwarf_callgraph) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); std::vector> workloads; CreateProcesses(1, &workloads); diff --git a/simpleperf/test_util.h b/simpleperf/test_util.h index f242c896..5d214269 100644 --- a/simpleperf/test_util.h +++ b/simpleperf/test_util.h @@ -40,3 +40,13 @@ bool IsRoot(); GTEST_LOG_(INFO) << "Didn't test \"" << #TestStatement << "\" requires root privileges"; \ } \ } while (0) + +bool IsInNativeAbi(); +// Used to skip tests not supposed to run on non-native ABIs. +#define OMIT_TEST_ON_NON_NATIVE_ABIS() \ + do { \ + if (!IsInNativeAbi()) { \ + GTEST_LOG_(INFO) << "Skip this test as it only runs on native ABIs."; \ + return; \ + } \ + } while (0)