1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "ProbeEvents.h"
18
19 #include <gtest/gtest.h>
20
21 #include "get_test_data.h"
22 #include "test_util.h"
23
24 using namespace simpleperf;
25
TEST(probe_events,ParseKprobeEventName)26 TEST(probe_events, ParseKprobeEventName) {
27 ProbeEvent event;
28 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p:myprobe do_sys_open", &event));
29 ASSERT_EQ(event.group_name, "kprobes");
30 ASSERT_EQ(event.event_name, "myprobe");
31
32 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p:mygroup/myprobe do_sys_open", &event));
33 ASSERT_EQ(event.group_name, "mygroup");
34 ASSERT_EQ(event.event_name, "myprobe");
35
36 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p do_sys_open", &event));
37 ASSERT_EQ(event.group_name, "kprobes");
38 ASSERT_EQ(event.event_name, "p_do_sys_open_0");
39
40 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("r do_sys_open+138", &event));
41 ASSERT_EQ(event.group_name, "kprobes");
42 ASSERT_EQ(event.event_name, "r_do_sys_open_138");
43
44 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("r module:do_sys_open+138", &event));
45 ASSERT_EQ(event.group_name, "kprobes");
46 ASSERT_EQ(event.event_name, "r_module_do_sys_open_138");
47
48 ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p 0x12345678", &event));
49 ASSERT_EQ(event.group_name, "kprobes");
50 ASSERT_EQ(event.event_name, "p_0x12345678");
51 }
52