summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-02-05 17:29:12 -0800
committerYabin Cui <yabinc@google.com>2020-02-05 17:29:12 -0800
commit2a9cad30e644086bb44bce5d19cbf09c8b455263 (patch)
tree2319c55111462bd084fd8b39196497ee6ceb6d2d /simpleperf/cmd_record_test.cpp
parentf2f1bf377dad884f3c61917920d80fb6f63b151a (diff)
downloadextras-2a9cad30e644086bb44bce5d19cbf09c8b455263.tar.gz
simpleperf: add --exclude-perf option in record cmd.
Bug: 148970587 Test: run simpleperf_unit_test. Change-Id: Ie6d869124f645c589eef06c6543aa0276836415c
Diffstat (limited to 'simpleperf/cmd_record_test.cpp')
-rw-r--r--simpleperf/cmd_record_test.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 207ec64c..f4ed1d87 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -1019,3 +1019,23 @@ TEST(record_cmd, pmu_event_option) {
}
TEST_IN_ROOT(ASSERT_TRUE(RunRecordCmd({"-e", event_string})));
}
+
+TEST(record_cmd, exclude_perf_option) {
+ ASSERT_TRUE(RunRecordCmd({"--exclude-perf"}));
+ if (IsRoot()) {
+ TemporaryFile tmpfile;
+ ASSERT_TRUE(RecordCmd()->Run(
+ {"-a", "--exclude-perf", "--duration", "1", "-e", GetDefaultEvent(), "-o", tmpfile.path}));
+ std::unique_ptr<RecordFileReader> reader = RecordFileReader::CreateInstance(tmpfile.path);
+ ASSERT_TRUE(reader);
+ pid_t perf_pid = getpid();
+ ASSERT_TRUE(reader->ReadDataSection([&](std::unique_ptr<Record> r) {
+ if (r->type() == PERF_RECORD_SAMPLE) {
+ if (static_cast<SampleRecord*>(r.get())->tid_data.pid == perf_pid) {
+ return false;
+ }
+ }
+ return true;
+ }));
+ }
+} \ No newline at end of file