Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Skip loading bpf_testmod when using -l to list tests.

When using "-l", test_progs often is executed as non-root user,
load_bpf_testmod() will fail and output errors. This patch skips loading bpf
testmod when "-l" is specified, making output cleaner.

Signed-off-by: Yucong Sun <fallentree@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210817044732.3263066-2-fallentree@fb.com

authored by

Yucong Sun and committed by
Andrii Nakryiko
26d82640 857f75ea

+2 -2
+2 -2
tools/testing/selftests/bpf/test_progs.c
··· 755 755 save_netns(); 756 756 stdio_hijack(); 757 757 env.has_testmod = true; 758 - if (load_bpf_testmod()) { 758 + if (!env.list_test_names && load_bpf_testmod()) { 759 759 fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); 760 760 env.has_testmod = false; 761 761 } ··· 803 803 if (test->need_cgroup_cleanup) 804 804 cleanup_cgroup_environment(); 805 805 } 806 - if (env.has_testmod) 806 + if (!env.list_test_names && env.has_testmod) 807 807 unload_bpf_testmod(); 808 808 stdio_restore(); 809 809