summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-10-14 10:24:38 -0700
committerYabin Cui <yabinc@google.com>2020-10-16 10:34:51 -0700
commit142acc899fc03502b7751704dab25558bcccc6a8 (patch)
tree5725a32a76d0ece247fbf0cfd0e659e420e00263 /simpleperf/cmd_record_test.cpp
parent3babe8947d5c07e68ecaeb1a0d2da62cd0181d4a (diff)
downloadextras-142acc899fc03502b7751704dab25558bcccc6a8.tar.gz
simpleperf: add --kprobe option to record cmd.
It adds temporary kprobe events during recording. The format of kprobe events follows Documentation/trace/kprobetrace.rst in the kernel. Also fix an error in event_type.cpp. Bug: 160630060 Test: run simpleperf_unit_test. Change-Id: Ib0c46a76e8d5900fd5df2f978763743a230b075d
Diffstat (limited to 'simpleperf/cmd_record_test.cpp')
-rw-r--r--simpleperf/cmd_record_test.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index 510d5be2..75a33ea5 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -40,6 +40,7 @@
#include "ETMRecorder.h"
#include "event_selection_set.h"
#include "get_test_data.h"
+#include "ProbeEvents.h"
#include "record.h"
#include "record_file.h"
#include "test_util.h"
@@ -290,8 +291,7 @@ static bool InCloudAndroid() {
bool HasTracepointEvents() {
static int has_tracepoint_events = -1;
if (has_tracepoint_events == -1) {
- // Cloud Android doesn't support tracepoint events.
- has_tracepoint_events = InCloudAndroid() ? 0 : 1;
+ has_tracepoint_events = (GetTraceFsDir() != nullptr) ? 1 : 0;
}
return has_tracepoint_events == 1;
}
@@ -507,10 +507,7 @@ TEST(record_cmd, no_dump_symbols) {
}
TEST(record_cmd, dump_kernel_symbols) {
- if (!IsRoot()) {
- GTEST_LOG_(INFO) << "Test requires root privilege";
- return;
- }
+ TEST_REQUIRE_ROOT();
TemporaryFile tmpfile;
ASSERT_TRUE(RecordCmd()->Run({"-a", "-o", tmpfile.path, "-e", GetDefaultEvent(), "sleep", "1"}));
bool has_kernel_symbols = false;
@@ -1131,3 +1128,13 @@ TEST(record_cmd, ParseAddrFilterOption) {
ASSERT_EQ(option_to_str("filter 0x12345678-0x1234567a"), "filter 0x12345678/0x2");
ASSERT_EQ(option_to_str("start 0x12345678,stop 0x1234567a"), "start 0x12345678,stop 0x1234567a");
}
+
+TEST(record_cmd, kprobe_option) {
+ TEST_REQUIRE_ROOT();
+ ProbeEvents probe_events;
+ if (!probe_events.IsKprobeSupported()) {
+ GTEST_LOG_(INFO) << "Skip this test as kprobe isn't supported by the kernel.";
+ return;
+ }
+ ASSERT_TRUE(RunRecordCmd({"-e", "kprobes:myprobe", "--kprobe", "p:myprobe do_sys_open"}));
+}