diff mbox series

[bpf-next] bpf, selftests: Skip verifier tests that fail to load with ENOTSUPP

Message ID 20211007173329.381754-1-iii@linux.ibm.com (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf-next] bpf, selftests: Skip verifier tests that fail to load with ENOTSUPP | expand

Checks

Context Check Description
netdev/cover_letter success Single patches do not need cover letters
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 9 maintainers not CCed: linux-kselftest@vger.kernel.org netdev@vger.kernel.org shuah@kernel.org kafai@fb.com yhs@fb.com andrii@kernel.org john.fastabend@gmail.com songliubraving@fb.com kpsingh@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch warning WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next success VM_Test

Commit Message

Ilya Leoshkevich Oct. 7, 2021, 5:33 p.m. UTC
The verifier tests added in commit c48e51c8b07a ("bpf: selftests: Add
selftests for module kfunc support") fail on s390, since the JIT does
not support calling kernel functions. This is most likely an issue for
all the other non-Intel arches, as well as on Intel with
!CONFIG_DEBUG_INFO_BTF or !CONFIG_BPF_JIT.

Trying to check for messages from all the possible add_kfunc_call()
failure cases in test_verifier looks pointless, so do a much simpler
thing instead: just like it's already done in do_prog_test_run(), skip
the tests that fail to load with ENOTSUPP.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tools/testing/selftests/bpf/test_verifier.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Song Liu Oct. 7, 2021, 10:27 p.m. UTC | #1
On Thu, Oct 7, 2021 at 12:44 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> The verifier tests added in commit c48e51c8b07a ("bpf: selftests: Add
> selftests for module kfunc support") fail on s390, since the JIT does
> not support calling kernel functions. This is most likely an issue for
> all the other non-Intel arches, as well as on Intel with
> !CONFIG_DEBUG_INFO_BTF or !CONFIG_BPF_JIT.
>
> Trying to check for messages from all the possible add_kfunc_call()
> failure cases in test_verifier looks pointless, so do a much simpler
> thing instead: just like it's already done in do_prog_test_run(), skip
> the tests that fail to load with ENOTSUPP.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

Acked-by: Song Liu <songliubraving@fb.com>
Andrii Nakryiko Oct. 9, 2021, 3:07 a.m. UTC | #2
On Thu, Oct 7, 2021 at 3:28 PM Song Liu <song@kernel.org> wrote:
>
> On Thu, Oct 7, 2021 at 12:44 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
> >
> > The verifier tests added in commit c48e51c8b07a ("bpf: selftests: Add
> > selftests for module kfunc support") fail on s390, since the JIT does
> > not support calling kernel functions. This is most likely an issue for
> > all the other non-Intel arches, as well as on Intel with
> > !CONFIG_DEBUG_INFO_BTF or !CONFIG_BPF_JIT.
> >
> > Trying to check for messages from all the possible add_kfunc_call()
> > failure cases in test_verifier looks pointless, so do a much simpler
> > thing instead: just like it's already done in do_prog_test_run(), skip
> > the tests that fail to load with ENOTSUPP.
> >
> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
>
> Acked-by: Song Liu <songliubraving@fb.com>

Applied to bpf-next, thanks.
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 3a9e332c5e36..25afe423b3f0 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -47,6 +47,10 @@ 
 #include "test_btf.h"
 #include "../../../include/linux/filter.h"
 
+#ifndef ENOTSUPP
+#define ENOTSUPP 524
+#endif
+
 #define MAX_INSNS	BPF_MAXINSNS
 #define MAX_TEST_INSNS	1000000
 #define MAX_FIXUPS	8
@@ -974,7 +978,7 @@  static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val,
 
 	if (err) {
 		switch (saved_errno) {
-		case 524/*ENOTSUPP*/:
+		case ENOTSUPP:
 			printf("Did not run the program (not supported) ");
 			return 0;
 		case EPERM:
@@ -1119,6 +1123,12 @@  static void do_test_single(struct bpf_test *test, bool unpriv,
 		goto close_fds;
 	}
 
+	if (fd_prog < 0 && saved_errno == ENOTSUPP) {
+		printf("SKIP (program uses an unsupported feature)\n");
+		skips++;
+		goto close_fds;
+	}
+
 	alignment_prevented_execution = 0;
 
 	if (expected_ret == ACCEPT || expected_ret == VERBOSE_ACCEPT) {