selftests/bpf: Add CO-RE relocs kfunc flavors tests
authorDave Marchevsky <davemarchevsky@fb.com>
Thu, 17 Aug 2023 22:53:53 +0000 (15:53 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 18 Aug 2023 16:12:59 +0000 (18:12 +0200)
commit63ae8eb2c5b1388eeda39bc95e89e4ad906fa336
tree4421cdd02656d6f376341fe86f52ee76354edeb5
parent5964a223f5e47a593c6ada9b9c54b61f04ac0a3b
selftests/bpf: Add CO-RE relocs kfunc flavors tests

This patch adds selftests that exercise kfunc flavor relocation
functionality added in the previous patch. The actual kfunc defined
in kernel/bpf/helpers.c is:

  struct task_struct *bpf_task_acquire(struct task_struct *p)

The following relocation behaviors are checked:

  struct task_struct *bpf_task_acquire___one(struct task_struct *name)
    * Should succeed despite differing param name

  struct task_struct *bpf_task_acquire___two(struct task_struct *p, void *ctx)
    * Should fail because there is no two-param bpf_task_acquire

  struct task_struct *bpf_task_acquire___three(void *ctx)
    * Should fail because, despite vmlinux's bpf_task_acquire having one param,
      the types don't match

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20230817225353.2570845-2-davemarchevsky@fb.com
tools/testing/selftests/bpf/prog_tests/task_kfunc.c
tools/testing/selftests/bpf/progs/task_kfunc_success.c