selftests/bpf: Add tests for filesystem kfuncs
authorSong Liu <song@kernel.org>
Wed, 29 Nov 2023 23:44:16 +0000 (15:44 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 2 Dec 2023 00:21:03 +0000 (16:21 -0800)
commit341f06fdddf72cd60a10945152f69f0f1d614519
tree0b17fcf04dd1fc3dd848eee2d9c2421b310c6587
parent6b0ae4566aba566a2ab4a2de9c59ab3d7f4b43c2
selftests/bpf: Add tests for filesystem kfuncs

Add selftests for two new filesystem kfuncs:
  1. bpf_get_file_xattr
  2. bpf_get_fsverity_digest

These tests simply make sure the two kfuncs work. Another selftest will be
added to demonstrate how to use these kfuncs to verify file signature.

CONFIG_FS_VERITY is added to selftests config. However, this is not
sufficient to guarantee bpf_get_fsverity_digest works. This is because
fsverity need to be enabled at file system level (for example, with tune2fs
on ext4). If local file system doesn't have this feature enabled, just skip
the test.

Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20231129234417.856536-6-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/bpf_kfuncs.h
tools/testing/selftests/bpf/config
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_fsverity.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_get_xattr.c [new file with mode: 0644]