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

selftests: vm: return Kselftest Skip code for skipped tests

When vm test is skipped because of unmet dependencies and/or unsupported
configuration, it exits with error which 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>
Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>

+17 -8
+3 -1
tools/testing/selftests/vm/compaction_test.c
··· 16 16 #include <unistd.h> 17 17 #include <string.h> 18 18 19 + #include "../kselftest.h" 20 + 19 21 #define MAP_SIZE 1048576 20 22 21 23 struct map_list { ··· 171 169 printf("Either the sysctl compact_unevictable_allowed is not\n" 172 170 "set to 1 or couldn't read the proc file.\n" 173 171 "Skipping the test\n"); 174 - return 0; 172 + return KSFT_SKIP; 175 173 } 176 174 177 175 lim.rlim_cur = RLIM_INFINITY;
+7 -5
tools/testing/selftests/vm/mlock2-tests.c
··· 9 9 #include <stdbool.h> 10 10 #include "mlock2.h" 11 11 12 + #include "../kselftest.h" 13 + 12 14 struct vm_boundaries { 13 15 unsigned long start; 14 16 unsigned long end; ··· 305 303 if (mlock2_(map, 2 * page_size, 0)) { 306 304 if (errno == ENOSYS) { 307 305 printf("Cannot call new mlock family, skipping test\n"); 308 - _exit(0); 306 + _exit(KSFT_SKIP); 309 307 } 310 308 perror("mlock2(0)"); 311 309 goto unmap; ··· 414 412 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 415 413 if (errno == ENOSYS) { 416 414 printf("Cannot call new mlock family, skipping test\n"); 417 - _exit(0); 415 + _exit(KSFT_SKIP); 418 416 } 419 417 perror("mlock2(MLOCK_ONFAULT)"); 420 418 goto unmap; ··· 427 425 if (munlock(map, 2 * page_size)) { 428 426 if (errno == ENOSYS) { 429 427 printf("Cannot call new mlock family, skipping test\n"); 430 - _exit(0); 428 + _exit(KSFT_SKIP); 431 429 } 432 430 perror("munlock()"); 433 431 goto unmap; ··· 459 457 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 460 458 if (errno == ENOSYS) { 461 459 printf("Cannot call new mlock family, skipping test\n"); 462 - _exit(0); 460 + _exit(KSFT_SKIP); 463 461 } 464 462 perror("mlock2(MLOCK_ONFAULT)"); 465 463 goto unmap; ··· 585 583 if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) { 586 584 if (errno == ENOSYS) { 587 585 printf("Cannot call new mlock family, skipping test\n"); 588 - _exit(0); 586 + _exit(KSFT_SKIP); 589 587 } 590 588 perror("mlock(ONFAULT)\n"); 591 589 goto out;
+4 -1
tools/testing/selftests/vm/run_vmtests
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 #please run as root 4 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 5 8 mnt=./huge 6 9 exitcode=0 7 10 ··· 39 36 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages 40 37 if [ $? -ne 0 ]; then 41 38 echo "Please run this test as root" 42 - exit 1 39 + exit $ksft_skip 43 40 fi 44 41 while read name size unit; do 45 42 if [ "$name" = "HugePages_Free:" ]; then
+3 -1
tools/testing/selftests/vm/userfaultfd.c
··· 69 69 #include <setjmp.h> 70 70 #include <stdbool.h> 71 71 72 + #include "../kselftest.h" 73 + 72 74 #ifdef __NR_userfaultfd 73 75 74 76 static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; ··· 1324 1322 int main(void) 1325 1323 { 1326 1324 printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); 1327 - return 0; 1325 + return KSFT_SKIP; 1328 1326 } 1329 1327 1330 1328 #endif /* __NR_userfaultfd */