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

selftests: lib: return Kselftest Skip code for skipped tests

When lib test(s) is skipped because of unmet dependencies and/or
unsupported configuration, it returns non-zero value hich is treated
as a fail by the Kselftest framework. This leads to false negative result
even when the test could not be run.

Change it to return kselftest skip code when a test gets skipped to
clearly report that the test could not be run.

Kselftest framework SKIP code is 4 and the framework prints appropriate
messages to indicate that the test is skipped.

Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>

+17 -6
+6 -2
tools/testing/selftests/lib/bitmap.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 + 4 + # Kselftest framework requirement - SKIP code is 4. 5 + ksft_skip=4 6 + 3 7 # Runs bitmap infrastructure tests using test_bitmap kernel module 4 8 if ! /sbin/modprobe -q -n test_bitmap; then 5 - echo "bitmap: [SKIP]" 6 - exit 77 9 + echo "bitmap: module test_bitmap is not found [SKIP]" 10 + exit $ksft_skip 7 11 fi 8 12 9 13 if /sbin/modprobe -q test_bitmap; then
+5 -2
tools/testing/selftests/lib/prime_numbers.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # Checks fast/slow prime_number generation for inconsistencies 4 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 5 8 if ! /sbin/modprobe -q -r prime_numbers; then 6 - echo "prime_numbers: [SKIP]" 7 - exit 77 9 + echo "prime_numbers: module prime_numbers is not found [SKIP]" 10 + exit $ksft_skip 8 11 fi 9 12 10 13 if /sbin/modprobe -q prime_numbers selftest=65536; then
+6 -2
tools/testing/selftests/lib/printf.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # Runs printf infrastructure using test_printf kernel module 4 + 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 4 8 if ! /sbin/modprobe -q -n test_printf; then 5 - echo "printf: [SKIP]" 6 - exit 77 9 + echo "printf: module test_printf is not found [SKIP]" 10 + exit $ksft_skip 7 11 fi 8 12 9 13 if /sbin/modprobe -q test_printf; then