• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 // @CddTest = 6.1/C-0-2
TEST(probe_events,ParseKprobeEventName)27 TEST(probe_events, ParseKprobeEventName) {
28   ProbeEvent event;
29   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p:myprobe do_sys_open", &event));
30   ASSERT_EQ(event.group_name, "kprobes");
31   ASSERT_EQ(event.event_name, "myprobe");
32 
33   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p:mygroup/myprobe do_sys_open", &event));
34   ASSERT_EQ(event.group_name, "mygroup");
35   ASSERT_EQ(event.event_name, "myprobe");
36 
37   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p do_sys_open", &event));
38   ASSERT_EQ(event.group_name, "kprobes");
39   ASSERT_EQ(event.event_name, "p_do_sys_open_0");
40 
41   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("r do_sys_open+138", &event));
42   ASSERT_EQ(event.group_name, "kprobes");
43   ASSERT_EQ(event.event_name, "r_do_sys_open_138");
44 
45   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("r module:do_sys_open+138", &event));
46   ASSERT_EQ(event.group_name, "kprobes");
47   ASSERT_EQ(event.event_name, "r_module_do_sys_open_138");
48 
49   ASSERT_TRUE(ProbeEvents::ParseKprobeEventName("p 0x12345678", &event));
50   ASSERT_EQ(event.group_name, "kprobes");
51   ASSERT_EQ(event.event_name, "p_0x12345678");
52 }
53