selftests/bpf: add assert for user stacks in test_task_stack
Subsystems (3)
PATCH 1/1 selftests/bpf: add assert for user stacks in test_task_stack
This is a follow up to:
commit b8e3a87a627b ("bpf: Add crosstask check to __bpf_get_stack").
This test ensures that the task iterator only gets a single user stack (for the current task).
--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 2 ++ tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c | 5 +++++ 2 files changed, 7 insertions(+)
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +2 -0
@@ -332,6 +332,8 @@ static void test_task_stack(void)do_dummy_read (skel->progs.dump_task_stack);do_dummy_read (skel->progs.get_task_user_stacks); +ASSERT_EQ (skel->bss->num_user_stacks,1 ,"num_user_stacks" ); +bpf_iter_task_stack__destroy (skel); }
tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c +5 -0
@@ -35,6 +35,8 @@ int dump_task_stack(struct bpf_iter__task *ctx)return 0 ; } +int num_user_stacks =0 ; + SEC("iter/task")int get_task_user_stacks (struct bpf_iter__task *ctx) {
@@ -51,6 +53,9 @@ int get_task_user_stacks(struct bpf_iter__task *ctx)if (res <=0 )return 0 ; +/* Only one task, the current one, should succeed */ + ++num_user_stacks; + buf_sz += res;/* If the verifier doesn't refine bpf_get_task_stack res, and instead
Signature · 1 line
2.39.3
Quoted 7 lines · Jordan Rome
This is a follow up to:
commitb8e3a87a627b("bpf: Add crosstask check to__bpf_get_stack").This test ensures that the task iterator only gets a single user stack (for the current task).
Signed-off-by Jordan Rome <[email protected]>
(based on the tests passing)
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 9 lines · On Sat, 11 Nov 2023 18:30:10 -0800 you wrote:
This is a follow up to:
commitb8e3a87a627b("bpf: Add crosstask check to__bpf_get_stack").This test ensures that the task iterator only gets a single user stack (for the current task).
Signed-off-by Jordan Rome <[email protected]>[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: add assert for user stacks in test_task_stack
https://git.kernel.org/bpf/bpf-next/c/727a92d62fd6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html