diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-14 07:28:28 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-14 07:28:28 +0000 |
commit | 74fe0c4226f1cf45ccebaa15973f5f631d284679 (patch) | |
tree | a18e6c10ea25f6cccda4fcda1420d93f8e9d95b0 | |
parent | 65ce74ebd4c06567bea3a6a4e843ad37a59c1bd3 (diff) | |
parent | 3035e41eb6d6e6dc89520aada7f74dc874c14a56 (diff) | |
download | extras-74fe0c4226f1cf45ccebaa15973f5f631d284679.tar.gz |
release-request-f0fc1aa1-730c-4deb-b1ff-e8ebeeccc4b5-for-git_oc-mr1-release-4335659 snap-temp-L85900000102427279
Change-Id: I28277470b5e2b2ee4e73de62721fd04b3b9a56d4
-rw-r--r-- | simpleperf/cmd_record_test.cpp | 31 | ||||
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 1 | ||||
-rw-r--r-- | simpleperf/test_util.h | 10 |
3 files changed, 42 insertions, 0 deletions
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 <gtest/gtest.h> +#include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <android-base/file.h> @@ -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<std::unique_ptr<Workload>> 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<std::unique_ptr<Workload>> 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<std::unique_ptr<Workload>> 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<Command> RecordCmd() { } TEST_F(ReportCommandTest, dwarf_callgraph) { + OMIT_TEST_ON_NON_NATIVE_ABIS(); ASSERT_TRUE(IsDwarfCallChainSamplingSupported()); std::vector<std::unique_ptr<Workload>> 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) |