Merge tag 'linux-kselftest-4.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest fixes from Shuah Khan:

- fix new sparc64 adi driver test compile errors on non-sparc systems

- fix config fragment for sync framework for improved test coverage

- fix several tests to return correct Kselftest skip code

* tag 'linux-kselftest-4.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: sparc64: Add missing SPDX License Identifiers
selftests: sparc64: delete RUN_TESTS and EMIT_TESTS overrides
selftests: sparc64: Fix to do nothing on non-sparc64
selftests: sync: add config fragment for testing sync framework
selftests: vm: return Kselftest Skip code for skipped tests
selftests: zram: return Kselftest Skip code for skipped tests
selftests: user: return Kselftest Skip code for skipped tests
selftests: sysctl: return Kselftest Skip code for skipped tests
selftests: static_keys: return Kselftest Skip code for skipped tests
selftests: pstore: return Kselftest Skip code for skipped tests

+79 -27
+4 -1
tools/testing/selftests/pstore/pstore_post_reboot_tests
··· 7 # 8 # Released under the terms of the GPL v2. 9 10 . ./common_tests 11 12 if [ -e $REBOOT_FLAG ]; then 13 rm $REBOOT_FLAG 14 else 15 prlog "pstore_crash_test has not been executed yet. we skip further tests." 16 - exit 0 17 fi 18 19 prlog -n "Mounting pstore filesystem ... "
··· 7 # 8 # Released under the terms of the GPL v2. 9 10 + # Kselftest framework requirement - SKIP code is 4. 11 + ksft_skip=4 12 + 13 . ./common_tests 14 15 if [ -e $REBOOT_FLAG ]; then 16 rm $REBOOT_FLAG 17 else 18 prlog "pstore_crash_test has not been executed yet. we skip further tests." 19 + exit $ksft_skip 20 fi 21 22 prlog -n "Mounting pstore filesystem ... "
+12 -8
tools/testing/selftests/sparc64/Makefile
··· 1 SUBDIRS := drivers 2 3 TEST_PROGS := run.sh 4 5 .PHONY: all clean 6 ··· 29 fi \ 30 done 31 32 - override define RUN_TESTS 33 - @cd $(OUTPUT); ./run.sh 34 - endef 35 - 36 override define INSTALL_RULE 37 mkdir -p $(INSTALL_PATH) 38 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) ··· 40 done; 41 endef 42 43 - override define EMIT_TESTS 44 - echo "./run.sh" 45 - endef 46 - 47 override define CLEAN 48 @for DIR in $(SUBDIRS); do \ 49 BUILD_TARGET=$(OUTPUT)/$$DIR; \ ··· 47 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 48 done 49 endef
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + uname_M := $(shell uname -m 2>/dev/null || echo not) 3 + ARCH ?= $(shell echo $(uname_M) | sed -e s/x86_64/x86/) 4 + 5 + ifneq ($(ARCH),sparc64) 6 + nothing: 7 + .PHONY: all clean run_tests install 8 + .SILENT: 9 + else 10 + 11 SUBDIRS := drivers 12 13 TEST_PROGS := run.sh 14 + 15 16 .PHONY: all clean 17 ··· 18 fi \ 19 done 20 21 override define INSTALL_RULE 22 mkdir -p $(INSTALL_PATH) 23 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) ··· 33 done; 34 endef 35 36 override define CLEAN 37 @for DIR in $(SUBDIRS); do \ 38 BUILD_TARGET=$(OUTPUT)/$$DIR; \ ··· 44 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 45 done 46 endef 47 + endif
+1 -1
tools/testing/selftests/sparc64/drivers/Makefile
··· 1 - 2 INCLUDEDIR := -I. 3 CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g 4
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 INCLUDEDIR := -I. 3 CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g 4
+13
tools/testing/selftests/static_keys/test_static_keys.sh
··· 2 # SPDX-License-Identifier: GPL-2.0 3 # Runs static keys kernel module tests 4 5 if /sbin/modprobe -q test_static_key_base; then 6 if /sbin/modprobe -q test_static_keys; then 7 echo "static_key: ok"
··· 2 # SPDX-License-Identifier: GPL-2.0 3 # Runs static keys kernel module tests 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 8 + if ! /sbin/modprobe -q -n test_static_key_base; then 9 + echo "static_key: module test_static_key_base is not found [SKIP]" 10 + exit $ksft_skip 11 + fi 12 + 13 + if ! /sbin/modprobe -q -n test_static_keys; then 14 + echo "static_key: module test_static_keys is not found [SKIP]" 15 + exit $ksft_skip 16 + fi 17 + 18 if /sbin/modprobe -q test_static_key_base; then 19 if /sbin/modprobe -q test_static_keys; then 20 echo "static_key: ok"
+4
tools/testing/selftests/sync/config
···
··· 1 + CONFIG_STAGING=y 2 + CONFIG_ANDROID=y 3 + CONFIG_SYNC=y 4 + CONFIG_SW_SYNC=y
+13 -7
tools/testing/selftests/sysctl/sysctl.sh
··· 14 15 # This performs a series tests against the proc sysctl interface. 16 17 TEST_NAME="sysctl" 18 TEST_DRIVER="test_${TEST_NAME}" 19 TEST_DIR=$(dirname $0) ··· 44 echo "$0: $DIR not present" >&2 45 echo "You must have the following enabled in your kernel:" >&2 46 cat $TEST_DIR/config >&2 47 - exit 1 48 fi 49 } 50 ··· 101 uid=$(id -u) 102 if [ $uid -ne 0 ]; then 103 echo $msg must be run as root >&2 104 - exit 0 105 fi 106 107 if ! which perl 2> /dev/null > /dev/null; then 108 echo "$0: You need perl installed" 109 - exit 1 110 fi 111 if ! which getconf 2> /dev/null > /dev/null; then 112 echo "$0: You need getconf installed" 113 - exit 1 114 fi 115 if ! which diff 2> /dev/null > /dev/null; then 116 echo "$0: You need diff installed" 117 - exit 1 118 fi 119 } 120 121 function load_req_mod() 122 { 123 - trap "test_modprobe" EXIT 124 - 125 if [ ! -d $DIR ]; then 126 modprobe $TEST_DRIVER 127 if [ $? -ne 0 ]; then 128 exit ··· 770 test_reqs 771 allow_user_defaults 772 check_production_sysctl_writes_strict 773 load_req_mod 774 775 trap "test_finish" EXIT
··· 14 15 # This performs a series tests against the proc sysctl interface. 16 17 + # Kselftest framework requirement - SKIP code is 4. 18 + ksft_skip=4 19 + 20 TEST_NAME="sysctl" 21 TEST_DRIVER="test_${TEST_NAME}" 22 TEST_DIR=$(dirname $0) ··· 41 echo "$0: $DIR not present" >&2 42 echo "You must have the following enabled in your kernel:" >&2 43 cat $TEST_DIR/config >&2 44 + exit $ksft_skip 45 fi 46 } 47 ··· 98 uid=$(id -u) 99 if [ $uid -ne 0 ]; then 100 echo $msg must be run as root >&2 101 + exit $ksft_skip 102 fi 103 104 if ! which perl 2> /dev/null > /dev/null; then 105 echo "$0: You need perl installed" 106 + exit $ksft_skip 107 fi 108 if ! which getconf 2> /dev/null > /dev/null; then 109 echo "$0: You need getconf installed" 110 + exit $ksft_skip 111 fi 112 if ! which diff 2> /dev/null > /dev/null; then 113 echo "$0: You need diff installed" 114 + exit $ksft_skip 115 fi 116 } 117 118 function load_req_mod() 119 { 120 if [ ! -d $DIR ]; then 121 + if ! modprobe -q -n $TEST_DRIVER; then 122 + echo "$0: module $TEST_DRIVER not found [SKIP]" 123 + exit $ksft_skip 124 + fi 125 modprobe $TEST_DRIVER 126 if [ $? -ne 0 ]; then 127 exit ··· 765 test_reqs 766 allow_user_defaults 767 check_production_sysctl_writes_strict 768 + test_modprobe 769 load_req_mod 770 771 trap "test_finish" EXIT
+7
tools/testing/selftests/user/test_user_copy.sh
··· 2 # SPDX-License-Identifier: GPL-2.0 3 # Runs copy_to/from_user infrastructure using test_user_copy kernel module 4 5 if /sbin/modprobe -q test_user_copy; then 6 /sbin/modprobe -q -r test_user_copy 7 echo "user_copy: ok"
··· 2 # SPDX-License-Identifier: GPL-2.0 3 # Runs copy_to/from_user infrastructure using test_user_copy kernel module 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 8 + if ! /sbin/modprobe -q -n test_user_copy; then 9 + echo "user: module test_user_copy is not found [SKIP]" 10 + exit $ksft_skip 11 + fi 12 if /sbin/modprobe -q test_user_copy; then 13 /sbin/modprobe -q -r test_user_copy 14 echo "user_copy: ok"
+3 -1
tools/testing/selftests/vm/compaction_test.c
··· 16 #include <unistd.h> 17 #include <string.h> 18 19 #define MAP_SIZE 1048576 20 21 struct map_list { ··· 171 printf("Either the sysctl compact_unevictable_allowed is not\n" 172 "set to 1 or couldn't read the proc file.\n" 173 "Skipping the test\n"); 174 - return 0; 175 } 176 177 lim.rlim_cur = RLIM_INFINITY;
··· 16 #include <unistd.h> 17 #include <string.h> 18 19 + #include "../kselftest.h" 20 + 21 #define MAP_SIZE 1048576 22 23 struct map_list { ··· 169 printf("Either the sysctl compact_unevictable_allowed is not\n" 170 "set to 1 or couldn't read the proc file.\n" 171 "Skipping the test\n"); 172 + return KSFT_SKIP; 173 } 174 175 lim.rlim_cur = RLIM_INFINITY;
+7 -5
tools/testing/selftests/vm/mlock2-tests.c
··· 9 #include <stdbool.h> 10 #include "mlock2.h" 11 12 struct vm_boundaries { 13 unsigned long start; 14 unsigned long end; ··· 305 if (mlock2_(map, 2 * page_size, 0)) { 306 if (errno == ENOSYS) { 307 printf("Cannot call new mlock family, skipping test\n"); 308 - _exit(0); 309 } 310 perror("mlock2(0)"); 311 goto unmap; ··· 414 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 415 if (errno == ENOSYS) { 416 printf("Cannot call new mlock family, skipping test\n"); 417 - _exit(0); 418 } 419 perror("mlock2(MLOCK_ONFAULT)"); 420 goto unmap; ··· 427 if (munlock(map, 2 * page_size)) { 428 if (errno == ENOSYS) { 429 printf("Cannot call new mlock family, skipping test\n"); 430 - _exit(0); 431 } 432 perror("munlock()"); 433 goto unmap; ··· 459 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 460 if (errno == ENOSYS) { 461 printf("Cannot call new mlock family, skipping test\n"); 462 - _exit(0); 463 } 464 perror("mlock2(MLOCK_ONFAULT)"); 465 goto unmap; ··· 585 if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) { 586 if (errno == ENOSYS) { 587 printf("Cannot call new mlock family, skipping test\n"); 588 - _exit(0); 589 } 590 perror("mlock(ONFAULT)\n"); 591 goto out;
··· 9 #include <stdbool.h> 10 #include "mlock2.h" 11 12 + #include "../kselftest.h" 13 + 14 struct vm_boundaries { 15 unsigned long start; 16 unsigned long end; ··· 303 if (mlock2_(map, 2 * page_size, 0)) { 304 if (errno == ENOSYS) { 305 printf("Cannot call new mlock family, skipping test\n"); 306 + _exit(KSFT_SKIP); 307 } 308 perror("mlock2(0)"); 309 goto unmap; ··· 412 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 413 if (errno == ENOSYS) { 414 printf("Cannot call new mlock family, skipping test\n"); 415 + _exit(KSFT_SKIP); 416 } 417 perror("mlock2(MLOCK_ONFAULT)"); 418 goto unmap; ··· 425 if (munlock(map, 2 * page_size)) { 426 if (errno == ENOSYS) { 427 printf("Cannot call new mlock family, skipping test\n"); 428 + _exit(KSFT_SKIP); 429 } 430 perror("munlock()"); 431 goto unmap; ··· 457 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 458 if (errno == ENOSYS) { 459 printf("Cannot call new mlock family, skipping test\n"); 460 + _exit(KSFT_SKIP); 461 } 462 perror("mlock2(MLOCK_ONFAULT)"); 463 goto unmap; ··· 583 if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) { 584 if (errno == ENOSYS) { 585 printf("Cannot call new mlock family, skipping test\n"); 586 + _exit(KSFT_SKIP); 587 } 588 perror("mlock(ONFAULT)\n"); 589 goto out;
+4 -1
tools/testing/selftests/vm/run_vmtests
··· 2 # SPDX-License-Identifier: GPL-2.0 3 #please run as root 4 5 mnt=./huge 6 exitcode=0 7 ··· 39 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages 40 if [ $? -ne 0 ]; then 41 echo "Please run this test as root" 42 - exit 1 43 fi 44 while read name size unit; do 45 if [ "$name" = "HugePages_Free:" ]; then
··· 2 # SPDX-License-Identifier: GPL-2.0 3 #please run as root 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 8 mnt=./huge 9 exitcode=0 10 ··· 36 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages 37 if [ $? -ne 0 ]; then 38 echo "Please run this test as root" 39 + exit $ksft_skip 40 fi 41 while read name size unit; do 42 if [ "$name" = "HugePages_Free:" ]; then
+3 -1
tools/testing/selftests/vm/userfaultfd.c
··· 69 #include <setjmp.h> 70 #include <stdbool.h> 71 72 #ifdef __NR_userfaultfd 73 74 static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; ··· 1324 int main(void) 1325 { 1326 printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); 1327 - return 0; 1328 } 1329 1330 #endif /* __NR_userfaultfd */
··· 69 #include <setjmp.h> 70 #include <stdbool.h> 71 72 + #include "../kselftest.h" 73 + 74 #ifdef __NR_userfaultfd 75 76 static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; ··· 1322 int main(void) 1323 { 1324 printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); 1325 + return KSFT_SKIP; 1326 } 1327 1328 #endif /* __NR_userfaultfd */
+4 -1
tools/testing/selftests/zram/zram.sh
··· 2 # SPDX-License-Identifier: GPL-2.0 3 TCID="zram.sh" 4 5 . ./zram_lib.sh 6 7 run_zram () { ··· 27 else 28 echo "$TCID : No zram.ko module or /dev/zram0 device file not found" 29 echo "$TCID : CONFIG_ZRAM is not set" 30 - exit 1 31 fi
··· 2 # SPDX-License-Identifier: GPL-2.0 3 TCID="zram.sh" 4 5 + # Kselftest framework requirement - SKIP code is 4. 6 + ksft_skip=4 7 + 8 . ./zram_lib.sh 9 10 run_zram () { ··· 24 else 25 echo "$TCID : No zram.ko module or /dev/zram0 device file not found" 26 echo "$TCID : CONFIG_ZRAM is not set" 27 + exit $ksft_skip 28 fi
+4 -1
tools/testing/selftests/zram/zram_lib.sh
··· 18 dev_makeswap=-1 19 dev_mounted=-1 20 21 trap INT 22 23 check_prereqs() ··· 30 31 if [ $uid -ne 0 ]; then 32 echo $msg must be run as root >&2 33 - exit 0 34 fi 35 } 36
··· 18 dev_makeswap=-1 19 dev_mounted=-1 20 21 + # Kselftest framework requirement - SKIP code is 4. 22 + ksft_skip=4 23 + 24 trap INT 25 26 check_prereqs() ··· 27 28 if [ $uid -ne 0 ]; then 29 echo $msg must be run as root >&2 30 + exit $ksft_skip 31 fi 32 } 33