@@ -122,6 +122,52 @@ static void test_attach_probe_manual(enum probe_attach_mode attach_mode)
122122 test_attach_probe_manual__destroy (skel );
123123}
124124
125+ /* attach uprobe/uretprobe long event name testings */
126+ static void test_attach_uprobe_long_event_name (void )
127+ {
128+ DECLARE_LIBBPF_OPTS (bpf_uprobe_opts , uprobe_opts );
129+ struct bpf_link * uprobe_link , * uretprobe_link ;
130+ struct test_attach_probe_manual * skel ;
131+ ssize_t uprobe_offset ;
132+ char path [PATH_MAX ] = {0 };
133+
134+ skel = test_attach_probe_manual__open_and_load ();
135+ if (!ASSERT_OK_PTR (skel , "skel_kprobe_manual_open_and_load" ))
136+ return ;
137+
138+ uprobe_offset = get_uprobe_offset (& trigger_func );
139+ if (!ASSERT_GE (uprobe_offset , 0 , "uprobe_offset" ))
140+ goto cleanup ;
141+
142+ if (!ASSERT_GT (readlink ("/proc/self/exe" , path , PATH_MAX - 1 ), 0 , "readlink" ))
143+ goto cleanup ;
144+
145+ /* manual-attach uprobe/uretprobe */
146+ uprobe_opts .attach_mode = PROBE_ATTACH_MODE_LEGACY ;
147+ uprobe_opts .ref_ctr_offset = 0 ;
148+ uprobe_opts .retprobe = false;
149+ uprobe_link = bpf_program__attach_uprobe_opts (skel -> progs .handle_uprobe ,
150+ 0 /* self pid */ ,
151+ path ,
152+ uprobe_offset ,
153+ & uprobe_opts );
154+ if (!ASSERT_OK_PTR (uprobe_link , "attach_uprobe_long_event_name" ))
155+ goto cleanup ;
156+ skel -> links .handle_uprobe = uprobe_link ;
157+
158+ uprobe_opts .retprobe = true;
159+ uretprobe_link = bpf_program__attach_uprobe_opts (skel -> progs .handle_uretprobe ,
160+ -1 /* any pid */ ,
161+ path ,
162+ uprobe_offset , & uprobe_opts );
163+ if (!ASSERT_OK_PTR (uretprobe_link , "attach_uretprobe_long_event_name" ))
164+ goto cleanup ;
165+ skel -> links .handle_uretprobe = uretprobe_link ;
166+
167+ cleanup :
168+ test_attach_probe_manual__destroy (skel );
169+ }
170+
125171static void test_attach_probe_auto (struct test_attach_probe * skel )
126172{
127173 struct bpf_link * uprobe_err_link ;
@@ -323,6 +369,9 @@ void test_attach_probe(void)
323369 if (test__start_subtest ("uprobe-ref_ctr" ))
324370 test_uprobe_ref_ctr (skel );
325371
372+ if (test__start_subtest ("uprobe-long_name" ))
373+ test_attach_uprobe_long_event_name ();
374+
326375cleanup :
327376 test_attach_probe__destroy (skel );
328377 ASSERT_EQ (uprobe_ref_ctr , 0 , "uprobe_ref_ctr_cleanup" );
0 commit comments