selftests/bpf: Add tests for fd_array_cnt
authorAnton Protopopov <aspsk@isovalent.com>
Fri, 13 Dec 2024 13:09:33 +0000 (13:09 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 13 Dec 2024 22:48:39 +0000 (14:48 -0800)
commit1c593d7402b13d97f997b570e9fc7c49e53e1ed1
tree12170c746d95f26fabe6033c28e112638139deaf
parentf9933acda31a9882b6e08f58cb976e67842a180b
selftests/bpf: Add tests for fd_array_cnt

Add a new set of tests to test the new field in PROG_LOAD-related
part of bpf_attr: fd_array_cnt.

Add the following test cases:

  * fd_array_cnt/no-fd-array: program is loaded in a normal
    way, without any fd_array present

  * fd_array_cnt/fd-array-ok: pass two extra non-used maps,
    check that they're bound to the program

  * fd_array_cnt/fd-array-dup-input: pass a few extra maps,
    only two of which are unique

  * fd_array_cnt/fd-array-ref-maps-in-array: pass a map in
    fd_array which is also referenced from within the program

  * fd_array_cnt/fd-array-trash-input: pass array with some trash

  * fd_array_cnt/fd-array-2big: pass too large array

All the tests above are using the bpf(2) syscall directly,
no libbpf involved.

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241213130934.1087929-7-aspsk@isovalent.com
tools/testing/selftests/bpf/prog_tests/fd_array.c [new file with mode: 0644]