[RFC bpf-next 08/10] selftests/bpf: Add uprobe session errors test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adding uprobe session test to check that just single
session instance is allowed or single uprobe.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
 .../bpf/prog_tests/uprobe_multi_test.c        | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
index fddca2597818..4bff681f0d7d 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
@@ -533,6 +533,31 @@ static void test_session_skel_api(void)
 	uprobe_multi_session__destroy(skel);
 }
 
+static void test_session_error_multiple_instances(void)
+{
+	struct uprobe_multi_session *skel_1 = NULL, *skel_2 = NULL;
+	int err;
+
+	skel_1 = uprobe_multi_session__open_and_load();
+	if (!ASSERT_OK_PTR(skel_1, "fentry_raw_skel_load"))
+		goto cleanup;
+
+	err = uprobe_multi_session__attach(skel_1);
+	if (!ASSERT_OK(err, " kprobe_multi_session__attach"))
+		goto cleanup;
+
+	skel_2 = uprobe_multi_session__open_and_load();
+	if (!ASSERT_OK_PTR(skel_2, "fentry_raw_skel_load"))
+		goto cleanup;
+
+	err = uprobe_multi_session__attach(skel_2);
+	ASSERT_EQ(err, -EBUSY, " kprobe_multi_session__attach");
+
+cleanup:
+	uprobe_multi_session__destroy(skel_1);
+	uprobe_multi_session__destroy(skel_2);
+}
+
 static void test_bench_attach_uprobe(void)
 {
 	long attach_start_ns = 0, attach_end_ns = 0;
@@ -623,4 +648,6 @@ void test_uprobe_multi_test(void)
 		test_attach_api_fails();
 	if (test__start_subtest("session"))
 		test_session_skel_api();
+	if (test__start_subtest("session_errors"))
+		test_session_error_multiple_instances();
 }
-- 
2.45.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux