diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-09-04 20:57:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-04 20:57:30 +0000 |
commit | 87c39032ab701d40befe8e36cdb5e7db22ff88e5 (patch) | |
tree | 7493fa2647e8c336da9417fbc87a52852265dcac | |
parent | 47096dff0e3a7debea0c704be7acb2045d2c5014 (diff) | |
parent | c3140091028bd5f77446cdfcb2179407724a98cb (diff) | |
download | extras-87c39032ab701d40befe8e36cdb5e7db22ff88e5.tar.gz |
Merge changes I10561d93,I05d248a7android-o-mr1-iot-release-1.0.4
* changes:
Perfprofd: Add TEST_MAPPING
Perfprofd: Disable tests when lacking arch_perfmon
-rw-r--r-- | perfprofd/TEST_MAPPING | 7 | ||||
-rw-r--r-- | perfprofd/tests/perfprofd_test.cc | 55 |
2 files changed, 62 insertions, 0 deletions
diff --git a/perfprofd/TEST_MAPPING b/perfprofd/TEST_MAPPING new file mode 100644 index 00000000..30101c2b --- /dev/null +++ b/perfprofd/TEST_MAPPING @@ -0,0 +1,7 @@ +{ + "presubmit": [ + { + "name": "perfprofd_test" + } + ] +}
\ No newline at end of file diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc index 530d5f49..bbb9a739 100644 --- a/perfprofd/tests/perfprofd_test.cc +++ b/perfprofd/tests/perfprofd_test.cc @@ -125,6 +125,29 @@ static bool bothWhiteSpace(char lhs, char rhs) return (std::isspace(lhs) && std::isspace(rhs)); } +#ifdef __ANDROID__ + +static bool IsPerfSupported() { + auto check_perf_supported = []() { +#if defined(__i386__) || defined(__x86_64__) + // Cloud devices may suppress perf. Check for arch_perfmon. + std::string cpuinfo; + if (!android::base::ReadFileToString("/proc/cpuinfo", &cpuinfo)) { + // This is pretty unexpected. Return true to see if we can run tests anyways. + return true; + } + return cpuinfo.find("arch_perfmon") != std::string::npos; +#else + // Expect other architectures to have perf support. + return true; +#endif + }; + static bool perf_supported = check_perf_supported(); + return perf_supported; +} + +#endif + // // Squeeze out repeated whitespace from expected/actual logs. // @@ -1246,6 +1269,10 @@ TEST_F(PerfProfdTest, CallchainRunWithCannedPerf) TEST_F(PerfProfdTest, GetSupportedPerfCounters) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } // Check basic perf counters. { struct DummyConfig : public Config { @@ -1264,6 +1291,10 @@ TEST_F(PerfProfdTest, GetSupportedPerfCounters) TEST_F(PerfProfdTest, BasicRunWithLivePerf) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } // // Basic test to exercise the main loop of the daemon. It includes // a live 'perf' run @@ -1387,6 +1418,10 @@ class PerfProfdLiveEventsTest : public PerfProfdTest { TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } const std::string expected = std::string( "I: starting Android Wide Profiling daemon ") + "I: config file path set to " + conf_dir + "/perfprofd.conf " + @@ -1404,6 +1439,10 @@ TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events) TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events_Strip) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } const std::string expected = std::string( "I: starting Android Wide Profiling daemon ") + "I: config file path set to " + conf_dir + "/perfprofd.conf " + @@ -1426,6 +1465,10 @@ TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events_Strip) TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events_NoStrip) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } const std::string expected = RAW_RESULT( W: Event does:not:exist is unsupported. @@ -1440,6 +1483,10 @@ TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_Events_NoStrip) TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_EventsGroup) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } const std::string expected = std::string( "I: starting Android Wide Profiling daemon ") + "I: config file path set to " + conf_dir + "/perfprofd.conf " + @@ -1457,6 +1504,10 @@ TEST_F(PerfProfdLiveEventsTest, BasicRunWithLivePerf_EventsGroup) TEST_F(PerfProfdTest, MultipleRunWithLivePerf) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } // // Basic test to exercise the main loop of the daemon. It includes // a live 'perf' run @@ -1530,6 +1581,10 @@ TEST_F(PerfProfdTest, MultipleRunWithLivePerf) TEST_F(PerfProfdTest, CallChainRunWithLivePerf) { + if (!IsPerfSupported()) { + std::cerr << "Test not supported!" << std::endl; + return; + } // // Collect a callchain profile, so as to exercise the code in // perf_data post-processing that digests callchains. |