lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250426160027.177173-4-mannkafai@gmail.com>
Date: Sun, 27 Apr 2025 00:00:26 +0800
From: KaFai Wan <mannkafai@...il.com>
To: song@...nel.org,
	jolsa@...nel.org,
	ast@...nel.org,
	daniel@...earbox.net,
	andrii@...nel.org,
	martin.lau@...ux.dev,
	eddyz87@...il.com,
	yonghong.song@...ux.dev,
	john.fastabend@...il.com,
	kpsingh@...nel.org,
	sdf@...ichev.me,
	haoluo@...gle.com,
	mattbobrowski@...gle.com,
	rostedt@...dmis.org,
	mhiramat@...nel.org,
	mathieu.desnoyers@...icios.com,
	davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	horms@...nel.org,
	mykolal@...com,
	shuah@...nel.org
Cc: linux-kernel@...r.kernel.org,
	bpf@...r.kernel.org,
	linux-trace-kernel@...r.kernel.org,
	netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	leon.hwang@...ux.dev,
	mannkafai@...il.com
Subject: [PATCH bpf-next 3/4] selftests/bpf: Add raw_tp_test_run for tp_btf

Add test runs test_run for tp_btf base on raw_tp.

Changing test_raw_tp_test_run to test both raw_tp and tp_btf.

Signed-off-by: KaFai Wan <mannkafai@...il.com>
---
 .../selftests/bpf/prog_tests/raw_tp_test_run.c | 18 ++++++++++++++++--
 .../selftests/bpf/progs/test_raw_tp_test_run.c | 16 +++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/raw_tp_test_run.c b/tools/testing/selftests/bpf/prog_tests/raw_tp_test_run.c
index fe5b8fae2c36..e2968a1e73bf 100644
--- a/tools/testing/selftests/bpf/prog_tests/raw_tp_test_run.c
+++ b/tools/testing/selftests/bpf/prog_tests/raw_tp_test_run.c
@@ -5,7 +5,7 @@
 #include "bpf/libbpf_internal.h"
 #include "test_raw_tp_test_run.skel.h"
 
-void test_raw_tp_test_run(void)
+static void test_raw_tp(bool is_tp_btf)
 {
 	int comm_fd = -1, err, nr_online, i, prog_fd;
 	__u64 args[2] = {0x1234ULL, 0x5678ULL};
@@ -28,6 +28,9 @@ void test_raw_tp_test_run(void)
 	if (!ASSERT_OK_PTR(skel, "skel_open"))
 		goto cleanup;
 
+	bpf_program__set_autoattach(skel->progs.rename_tp_btf, is_tp_btf);
+	bpf_program__set_autoattach(skel->progs.rename_raw_tp, !is_tp_btf);
+
 	err = test_raw_tp_test_run__attach(skel);
 	if (!ASSERT_OK(err, "skel_attach"))
 		goto cleanup;
@@ -42,7 +45,10 @@ void test_raw_tp_test_run(void)
 	ASSERT_NEQ(skel->bss->count, 0, "check_count");
 	ASSERT_EQ(skel->data->on_cpu, 0xffffffff, "check_on_cpu");
 
-	prog_fd = bpf_program__fd(skel->progs.rename);
+	if (is_tp_btf)
+		prog_fd = bpf_program__fd(skel->progs.rename_tp_btf);
+	else
+		prog_fd = bpf_program__fd(skel->progs.rename_raw_tp);
 	opts.ctx_in = args;
 	opts.ctx_size_in = sizeof(__u64);
 
@@ -84,3 +90,11 @@ void test_raw_tp_test_run(void)
 	test_raw_tp_test_run__destroy(skel);
 	free(online);
 }
+
+void test_raw_tp_test_run(void)
+{
+	if (test__start_subtest("raw_tp"))
+		test_raw_tp(false);
+	if (test__start_subtest("tp_btf"))
+		test_raw_tp(true);
+}
diff --git a/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c b/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
index 4c63cc87b9d0..ddc22e6cfdd9 100644
--- a/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
+++ b/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c
@@ -8,10 +8,8 @@
 __u32 count = 0;
 __u32 on_cpu = 0xffffffff;
 
-SEC("raw_tp/task_rename")
-int BPF_PROG(rename, struct task_struct *task, char *comm)
+static __always_inline int check_test_run(struct task_struct *task, char *comm)
 {
-
 	count++;
 	if ((__u64) task == 0x1234ULL && (__u64) comm == 0x5678ULL) {
 		on_cpu = bpf_get_smp_processor_id();
@@ -21,4 +19,16 @@ int BPF_PROG(rename, struct task_struct *task, char *comm)
 	return 0;
 }
 
+SEC("raw_tp/task_rename")
+int BPF_PROG(rename_raw_tp, struct task_struct *task, char *comm)
+{
+	return check_test_run(task, comm);
+}
+
+SEC("tp_btf/task_rename")
+int BPF_PROG(rename_tp_btf, struct task_struct *task, char *comm)
+{
+	return check_test_run(task, comm);
+}
+
 char _license[] SEC("license") = "GPL";
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ