@@ -69,8 +69,73 @@ static void test_skel_api(void)
69
69
uprobe_multi__destroy (skel );
70
70
}
71
71
72
+ static void
73
+ test_attach_api (const char * binary , const char * pattern , struct bpf_uprobe_multi_opts * opts )
74
+ {
75
+ struct uprobe_multi * skel = NULL ;
76
+
77
+ skel = uprobe_multi__open_and_load ();
78
+ if (!ASSERT_OK_PTR (skel , "uprobe_multi__open_and_load" ))
79
+ goto cleanup ;
80
+
81
+ opts -> retprobe = false;
82
+ skel -> links .uprobe = bpf_program__attach_uprobe_multi (skel -> progs .uprobe , -1 ,
83
+ binary , pattern , opts );
84
+ if (!ASSERT_OK_PTR (skel -> links .uprobe , "bpf_program__attach_uprobe_multi" ))
85
+ goto cleanup ;
86
+
87
+ opts -> retprobe = true;
88
+ skel -> links .uretprobe = bpf_program__attach_uprobe_multi (skel -> progs .uretprobe , -1 ,
89
+ binary , pattern , opts );
90
+ if (!ASSERT_OK_PTR (skel -> links .uretprobe , "bpf_program__attach_uprobe_multi" ))
91
+ goto cleanup ;
92
+
93
+ opts -> retprobe = false;
94
+ skel -> links .uprobe_sleep = bpf_program__attach_uprobe_multi (skel -> progs .uprobe_sleep , -1 ,
95
+ binary , pattern , opts );
96
+ if (!ASSERT_OK_PTR (skel -> links .uprobe_sleep , "bpf_program__attach_uprobe_multi" ))
97
+ goto cleanup ;
98
+
99
+ opts -> retprobe = true;
100
+ skel -> links .uretprobe_sleep = bpf_program__attach_uprobe_multi (skel -> progs .uretprobe_sleep ,
101
+ -1 , binary , pattern , opts );
102
+ if (!ASSERT_OK_PTR (skel -> links .uretprobe_sleep , "bpf_program__attach_uprobe_multi" ))
103
+ goto cleanup ;
104
+
105
+ uprobe_multi_test_run (skel );
106
+
107
+ cleanup :
108
+ uprobe_multi__destroy (skel );
109
+ }
110
+
111
+ static void test_attach_api_pattern (void )
112
+ {
113
+ LIBBPF_OPTS (bpf_uprobe_multi_opts , opts );
114
+
115
+ test_attach_api ("/proc/self/exe" , "uprobe_multi_func_*" , & opts );
116
+ test_attach_api ("/proc/self/exe" , "uprobe_multi_func_?" , & opts );
117
+ }
118
+
119
+ static void test_attach_api_syms (void )
120
+ {
121
+ LIBBPF_OPTS (bpf_uprobe_multi_opts , opts );
122
+ const char * syms [3 ] = {
123
+ "uprobe_multi_func_1" ,
124
+ "uprobe_multi_func_2" ,
125
+ "uprobe_multi_func_3" ,
126
+ };
127
+
128
+ opts .syms = syms ;
129
+ opts .cnt = ARRAY_SIZE (syms );
130
+ test_attach_api ("/proc/self/exe" , NULL , & opts );
131
+ }
132
+
72
133
void test_uprobe_multi_test (void )
73
134
{
74
135
if (test__start_subtest ("skel_api" ))
75
136
test_skel_api ();
137
+ if (test__start_subtest ("attach_api_pattern" ))
138
+ test_attach_api_pattern ();
139
+ if (test__start_subtest ("attach_api_syms" ))
140
+ test_attach_api_syms ();
76
141
}
0 commit comments