diff options
author | Yabin Cui <yabinc@google.com> | 2016-03-10 11:49:57 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-03-10 13:54:12 -0800 |
commit | 0356f47c4faf6075348ce340ca0b0cc46cee060f (patch) | |
tree | 3aa5556a0b3a3f90a6e31cef56a86b6b5e826ae6 | |
parent | 9627638747d7418dc3be9617a99a33c688e3bf87 (diff) | |
download | extras-0356f47c4faf6075348ce340ca0b0cc46cee060f.tar.gz |
simpleperf: check if dwarf callgraph is supported by kernel before testing.
Move inclusion of poll.h from header files to source files,
as event_selection_set.h is used by cmd_report_test.cpp, which
can be built on windows.
Bug: 27590546
Change-Id: Ic6b141a93d96610f911ab52da1d927b7f619ccb2
(cherry picked from commit 19e6b6d372a1244189dc2df62313085a61ed1a80)
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 16 | ||||
-rw-r--r-- | simpleperf/event_fd.cpp | 1 | ||||
-rw-r--r-- | simpleperf/event_fd.h | 3 | ||||
-rw-r--r-- | simpleperf/event_selection_set.cpp | 2 | ||||
-rw-r--r-- | simpleperf/event_selection_set.h | 3 |
5 files changed, 18 insertions, 7 deletions
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp index a5ece01b..e27f71e6 100644 --- a/simpleperf/cmd_report_test.cpp +++ b/simpleperf/cmd_report_test.cpp @@ -24,6 +24,7 @@ #include <android-base/test_utils.h> #include "command.h" +#include "event_selection_set.h" #include "get_test_data.h" #include "read_apk.h" #include "test_util.h" @@ -252,17 +253,22 @@ TEST_F(ReportCommandTest, use_branch_address) { hit_set.end()); } -#if defined(__ANDROID__) || defined(__linux__) +#if defined(__linux__) static std::unique_ptr<Command> RecordCmd() { return CreateCommandInstance("record"); } TEST_F(ReportCommandTest, dwarf_callgraph) { - TemporaryFile tmp_file; - ASSERT_TRUE(RecordCmd()->Run({"-g", "-o", tmp_file.path, "sleep", SLEEP_SEC})); - ReportRaw(tmp_file.path, {"-g"}); - ASSERT_TRUE(success); + if (IsDwarfCallChainSamplingSupported()) { + TemporaryFile tmp_file; + ASSERT_TRUE(RecordCmd()->Run({"-g", "-o", tmp_file.path, "sleep", SLEEP_SEC})); + ReportRaw(tmp_file.path, {"-g"}); + ASSERT_TRUE(success); + } else { + GTEST_LOG_(INFO) + << "This test does nothing as dwarf callchain sampling is not supported on this device."; + } } #endif diff --git a/simpleperf/event_fd.cpp b/simpleperf/event_fd.cpp index ec06f6fd..808639bd 100644 --- a/simpleperf/event_fd.cpp +++ b/simpleperf/event_fd.cpp @@ -17,6 +17,7 @@ #include "event_fd.h" #include <fcntl.h> +#include <poll.h> #include <stdio.h> #include <string.h> #include <sys/ioctl.h> diff --git a/simpleperf/event_fd.h b/simpleperf/event_fd.h index cc0c0618..c1a7d753 100644 --- a/simpleperf/event_fd.h +++ b/simpleperf/event_fd.h @@ -17,7 +17,6 @@ #ifndef SIMPLE_PERF_EVENT_FD_H_ #define SIMPLE_PERF_EVENT_FD_H_ -#include <poll.h> #include <sys/types.h> #include <memory> @@ -35,6 +34,8 @@ struct PerfCounter { uint64_t id; // The id of the perf_event_file. }; +struct pollfd; + // EventFd represents an opened perf_event_file. class EventFd { public: diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp index df731f1a..d99966a2 100644 --- a/simpleperf/event_selection_set.cpp +++ b/simpleperf/event_selection_set.cpp @@ -16,6 +16,8 @@ #include "event_selection_set.h" +#include <poll.h> + #include <android-base/logging.h> #include <android-base/stringprintf.h> diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index cba9dc62..746abfa7 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -17,7 +17,6 @@ #ifndef SIMPLE_PERF_EVENT_SELECTION_SET_H_ #define SIMPLE_PERF_EVENT_SELECTION_SET_H_ -#include <poll.h> #include <functional> #include <map> #include <vector> @@ -38,6 +37,8 @@ struct CountersInfo { std::vector<CounterInfo> counters; }; +struct pollfd; + // EventSelectionSet helps to monitor events. // Firstly, the user creates an EventSelectionSet, and adds the specific event types to monitor. // Secondly, the user defines how to monitor the events (by setting enable_on_exec flag, |