Skip to content

Commit 954fa97

Browse files
etsalAlexei Starovoitov
authored andcommitted
selftests/bpf: Add selftests for bpf_stream_print_stack
Add selftests for the new bpf_stream_print_stack kfunc. Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20260203180424.14057-3-emil@etsalapatis.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 63328bb commit 954fa97

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • tools/testing/selftests/bpf/progs

tools/testing/selftests/bpf/progs/stream.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,25 @@ int stream_arena_callback_fault(void *ctx)
234234
return 0;
235235
}
236236

237+
SEC("syscall")
238+
__arch_x86_64
239+
__arch_arm64
240+
__success __retval(0)
241+
__stderr("CPU: {{[0-9]+}} UID: 0 PID: {{[0-9]+}} Comm: {{.*}}")
242+
__stderr("Call trace:\n"
243+
"{{([a-zA-Z_][a-zA-Z0-9_]*\\+0x[0-9a-fA-F]+/0x[0-9a-fA-F]+\n"
244+
"|[ \t]+[^\n]+\n)*}}")
245+
int stream_print_stack_kfunc(void *ctx)
246+
{
247+
return bpf_stream_print_stack(BPF_STDERR);
248+
}
249+
250+
SEC("syscall")
251+
__success __retval(-2)
252+
int stream_print_stack_invalid_id(void *ctx)
253+
{
254+
/* Try to pass an invalid stream ID. */
255+
return bpf_stream_print_stack((enum bpf_stream_id)0xbadcafe);
256+
}
257+
237258
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)