diff options
author | 2020-09-25 13:54:31 -0700 | |
---|---|---|
committer | 2020-09-28 21:52:36 +0200 | |
commit | 09d8ad16885ee2ea3b9a4d4735ae053f425a1faf (patch) | |
tree | 29a4777062105484362120c0279d2d3a9a3b91c7 /tools/testing/selftests/bpf/progs | |
parent | libbpf: Support test run of raw tracepoint programs (diff) | |
download | wireguard-linux-09d8ad16885ee2ea3b9a4d4735ae053f425a1faf.tar.xz wireguard-linux-09d8ad16885ee2ea3b9a4d4735ae053f425a1faf.zip |
selftests/bpf: Add raw_tp_test_run
This test runs test_run for raw_tracepoint program. The test covers ctx
input, retval output, and running on correct cpu.
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200925205432.1777-4-songliubraving@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 new file mode 100644 index 000000000000..1521853597d7 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/test_raw_tp_test_run.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2020 Facebook */ + +#include "vmlinux.h" +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +__u32 count = 0; +__u32 on_cpu = 0xffffffff; + +SEC("raw_tp/task_rename") +int BPF_PROG(rename, struct task_struct *task, char *comm) +{ + + count++; + if ((__u64) task == 0x1234ULL && (__u64) comm == 0x5678ULL) { + on_cpu = bpf_get_smp_processor_id(); + return (int)task + (int)comm; + } + + return 0; +} + +char _license[] SEC("license") = "GPL"; |