@@ -69,8 +69,79 @@ static void test_skel_api(void)
uprobe_multi__destroy(skel);
}
+static void
+test_attach_api(const char *binary, const char *pattern, struct bpf_uprobe_multi_opts *opts)
+{
+ struct bpf_link *link1 = NULL, *link2 = NULL;
+ struct bpf_link *link3 = NULL, *link4 = NULL;
+ struct uprobe_multi *skel = NULL;
+
+ skel = uprobe_multi__open_and_load();
+ if (!ASSERT_OK_PTR(skel, "uprobe_multi__open_and_load"))
+ goto cleanup;
+
+ opts->retprobe = false;
+ link1 = bpf_program__attach_uprobe_multi_opts(skel->progs.test_uprobe, -1,
+ binary, pattern, opts);
+ if (!ASSERT_OK_PTR(link1, "bpf_program__attach_uprobe_multi_opts"))
+ goto cleanup;
+
+ opts->retprobe = true;
+ link2 = bpf_program__attach_uprobe_multi_opts(skel->progs.test_uretprobe, -1,
+ binary, pattern, opts);
+ if (!ASSERT_OK_PTR(link2, "bpf_program__attach_uprobe_multi_opts_retprobe"))
+ goto cleanup;
+
+ opts->retprobe = false;
+ link3 = bpf_program__attach_uprobe_multi_opts(skel->progs.test_uprobe_sleep, -1,
+ binary, pattern, opts);
+ if (!ASSERT_OK_PTR(link1, "bpf_program__attach_uprobe_multi_opts"))
+ goto cleanup;
+
+ opts->retprobe = true;
+ link4 = bpf_program__attach_uprobe_multi_opts(skel->progs.test_uretprobe_sleep, -1,
+ binary, pattern, opts);
+ if (!ASSERT_OK_PTR(link2, "bpf_program__attach_uprobe_multi_opts_retprobe"))
+ goto cleanup;
+
+ uprobe_multi_test_run(skel);
+
+cleanup:
+ bpf_link__destroy(link4);
+ bpf_link__destroy(link3);
+ bpf_link__destroy(link2);
+ bpf_link__destroy(link1);
+ uprobe_multi__destroy(skel);
+}
+
+static void test_attach_api_pattern(void)
+{
+ LIBBPF_OPTS(bpf_uprobe_multi_opts, opts);
+
+ test_attach_api("/proc/self/exe", "uprobe_multi_func_*", &opts);
+ test_attach_api("/proc/self/exe", "uprobe_multi_func_?", &opts);
+}
+
+static void test_attach_api_syms(void)
+{
+ LIBBPF_OPTS(bpf_uprobe_multi_opts, opts);
+ const char *syms[3] = {
+ "uprobe_multi_func_1",
+ "uprobe_multi_func_2",
+ "uprobe_multi_func_3",
+ };
+
+ opts.syms = syms;
+ opts.cnt = ARRAY_SIZE(syms);
+ test_attach_api("/proc/self/exe", NULL, &opts);
+}
+
void test_uprobe_multi_test(void)
{
if (test__start_subtest("skel_api"))
test_skel_api();
+ if (test__start_subtest("attach_api_pattern"))
+ test_attach_api_pattern();
+ if (test__start_subtest("attach_api_syms"))
+ test_attach_api_syms();
}
Adding uprobe_multi test for bpf_program__attach_uprobe_multi_opts attach function. Testing attachment using glob patterns and via bpf_uprobe_multi_opts paths/syms fields. Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- .../bpf/prog_tests/uprobe_multi_test.c | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+)