summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-09-14 01:45:39 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-09-14 01:45:39 +0000
commit1486c2cb0721be255b5b7cb834afe2559a67892c (patch)
tree0f3d2ebdec0bf24be89f4da2afd122726d06b7e1
parent390c1a849ea3ce062104f11ef91dd5aadf1302a3 (diff)
parent64a9ecda2c006f90dcc047ad95be792139622ead (diff)
downloadextras-1486c2cb0721be255b5b7cb834afe2559a67892c.tar.gz
Merge "simpleperf: Omit dwarf-callgraph tests running on arm translation tools."
-rw-r--r--simpleperf/cmd_record_test.cpp32
-rw-r--r--simpleperf/cmd_report_test.cpp2
-rw-r--r--simpleperf/test_util.h10
3 files changed, 44 insertions, 0 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 61228ac5..b0c18622 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>
@@ -191,7 +193,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);
@@ -203,17 +229,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);
@@ -332,6 +361,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);
@@ -471,6 +501,7 @@ TEST(record_cmd, cpu_clock_for_a_long_time) {
TEST(record_cmd, dump_regs_for_tracepoint_events) {
TEST_REQUIRE_HOST_ROOT();
+ 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"
@@ -480,6 +511,7 @@ TEST(record_cmd, dump_regs_for_tracepoint_events) {
TEST(record_cmd, trace_offcpu_option) {
// On linux host, we need root privilege to read tracepoint events.
TEST_REQUIRE_HOST_ROOT();
+ OMIT_TEST_ON_NON_NATIVE_ABIS();
TemporaryFile tmpfile;
ASSERT_TRUE(RunRecordCmd({"--trace-offcpu", "-f", "1000"}, tmpfile.path));
std::unique_ptr<RecordFileReader> reader = RecordFileReader::CreateInstance(tmpfile.path);
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index 05ffc184..f6ab6f8f 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -494,6 +494,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);
@@ -523,6 +524,7 @@ TEST_F(ReportCommandTest, report_dwarf_callgraph_of_nativelib_in_apk) {
TEST_F(ReportCommandTest, exclude_kernel_callchain) {
TEST_REQUIRE_HOST_ROOT();
+ OMIT_TEST_ON_NON_NATIVE_ABIS();
std::vector<std::unique_ptr<Workload>> workloads;
CreateProcesses(1, &workloads);
std::string pid = std::to_string(workloads[0]->GetPid());
diff --git a/simpleperf/test_util.h b/simpleperf/test_util.h
index bb061ba2..f5fb590f 100644
--- a/simpleperf/test_util.h
+++ b/simpleperf/test_util.h
@@ -46,3 +46,13 @@ bool IsRoot();
#else
#define TEST_REQUIRE_HOST_ROOT() if (!IsRoot()) return
#endif
+
+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)