Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-4.18-rc2' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Jun 23, 2018
2 parents 81f9c4e + eb83d5f commit b13fbe7
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 27 deletions.
5 changes: 4 additions & 1 deletion tools/testing/selftests/pstore/pstore_post_reboot_tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
#
# Released under the terms of the GPL v2.

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

. ./common_tests

if [ -e $REBOOT_FLAG ]; then
rm $REBOOT_FLAG
else
prlog "pstore_crash_test has not been executed yet. we skip further tests."
exit 0
exit $ksft_skip
fi

prlog -n "Mounting pstore filesystem ... "
Expand Down
20 changes: 12 additions & 8 deletions tools/testing/selftests/sparc64/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# SPDX-License-Identifier: GPL-2.0
uname_M := $(shell uname -m 2>/dev/null || echo not)
ARCH ?= $(shell echo $(uname_M) | sed -e s/x86_64/x86/)

ifneq ($(ARCH),sparc64)
nothing:
.PHONY: all clean run_tests install
.SILENT:
else

SUBDIRS := drivers

TEST_PROGS := run.sh


.PHONY: all clean

include ../lib.mk
Expand All @@ -18,10 +29,6 @@ all:
fi \
done

override define RUN_TESTS
@cd $(OUTPUT); ./run.sh
endef

override define INSTALL_RULE
mkdir -p $(INSTALL_PATH)
install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
Expand All @@ -33,14 +40,11 @@ override define INSTALL_RULE
done;
endef

override define EMIT_TESTS
echo "./run.sh"
endef

override define CLEAN
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
done
endef
endif
2 changes: 1 addition & 1 deletion tools/testing/selftests/sparc64/drivers/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# SPDX-License-Identifier: GPL-2.0
INCLUDEDIR := -I.
CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g

Expand Down
13 changes: 13 additions & 0 deletions tools/testing/selftests/static_keys/test_static_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
# SPDX-License-Identifier: GPL-2.0
# Runs static keys kernel module tests

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

if ! /sbin/modprobe -q -n test_static_key_base; then
echo "static_key: module test_static_key_base is not found [SKIP]"
exit $ksft_skip
fi

if ! /sbin/modprobe -q -n test_static_keys; then
echo "static_key: module test_static_keys is not found [SKIP]"
exit $ksft_skip
fi

if /sbin/modprobe -q test_static_key_base; then
if /sbin/modprobe -q test_static_keys; then
echo "static_key: ok"
Expand Down
4 changes: 4 additions & 0 deletions tools/testing/selftests/sync/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_STAGING=y
CONFIG_ANDROID=y
CONFIG_SYNC=y
CONFIG_SW_SYNC=y
20 changes: 13 additions & 7 deletions tools/testing/selftests/sysctl/sysctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

# This performs a series tests against the proc sysctl interface.

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

TEST_NAME="sysctl"
TEST_DRIVER="test_${TEST_NAME}"
TEST_DIR=$(dirname $0)
Expand Down Expand Up @@ -41,7 +44,7 @@ test_modprobe()
echo "$0: $DIR not present" >&2
echo "You must have the following enabled in your kernel:" >&2
cat $TEST_DIR/config >&2
exit 1
exit $ksft_skip
fi
}

Expand Down Expand Up @@ -98,28 +101,30 @@ test_reqs()
uid=$(id -u)
if [ $uid -ne 0 ]; then
echo $msg must be run as root >&2
exit 0
exit $ksft_skip
fi

if ! which perl 2> /dev/null > /dev/null; then
echo "$0: You need perl installed"
exit 1
exit $ksft_skip
fi
if ! which getconf 2> /dev/null > /dev/null; then
echo "$0: You need getconf installed"
exit 1
exit $ksft_skip
fi
if ! which diff 2> /dev/null > /dev/null; then
echo "$0: You need diff installed"
exit 1
exit $ksft_skip
fi
}

function load_req_mod()
{
trap "test_modprobe" EXIT

if [ ! -d $DIR ]; then
if ! modprobe -q -n $TEST_DRIVER; then
echo "$0: module $TEST_DRIVER not found [SKIP]"
exit $ksft_skip
fi
modprobe $TEST_DRIVER
if [ $? -ne 0 ]; then
exit
Expand Down Expand Up @@ -765,6 +770,7 @@ function parse_args()
test_reqs
allow_user_defaults
check_production_sysctl_writes_strict
test_modprobe
load_req_mod

trap "test_finish" EXIT
Expand Down
7 changes: 7 additions & 0 deletions tools/testing/selftests/user/test_user_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# SPDX-License-Identifier: GPL-2.0
# Runs copy_to/from_user infrastructure using test_user_copy kernel module

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

if ! /sbin/modprobe -q -n test_user_copy; then
echo "user: module test_user_copy is not found [SKIP]"
exit $ksft_skip
fi
if /sbin/modprobe -q test_user_copy; then
/sbin/modprobe -q -r test_user_copy
echo "user_copy: ok"
Expand Down
4 changes: 3 additions & 1 deletion tools/testing/selftests/vm/compaction_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <unistd.h>
#include <string.h>

#include "../kselftest.h"

#define MAP_SIZE 1048576

struct map_list {
Expand Down Expand Up @@ -169,7 +171,7 @@ int main(int argc, char **argv)
printf("Either the sysctl compact_unevictable_allowed is not\n"
"set to 1 or couldn't read the proc file.\n"
"Skipping the test\n");
return 0;
return KSFT_SKIP;
}

lim.rlim_cur = RLIM_INFINITY;
Expand Down
12 changes: 7 additions & 5 deletions tools/testing/selftests/vm/mlock2-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <stdbool.h>
#include "mlock2.h"

#include "../kselftest.h"

struct vm_boundaries {
unsigned long start;
unsigned long end;
Expand Down Expand Up @@ -303,7 +305,7 @@ static int test_mlock_lock()
if (mlock2_(map, 2 * page_size, 0)) {
if (errno == ENOSYS) {
printf("Cannot call new mlock family, skipping test\n");
_exit(0);
_exit(KSFT_SKIP);
}
perror("mlock2(0)");
goto unmap;
Expand Down Expand Up @@ -412,7 +414,7 @@ static int test_mlock_onfault()
if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
if (errno == ENOSYS) {
printf("Cannot call new mlock family, skipping test\n");
_exit(0);
_exit(KSFT_SKIP);
}
perror("mlock2(MLOCK_ONFAULT)");
goto unmap;
Expand All @@ -425,7 +427,7 @@ static int test_mlock_onfault()
if (munlock(map, 2 * page_size)) {
if (errno == ENOSYS) {
printf("Cannot call new mlock family, skipping test\n");
_exit(0);
_exit(KSFT_SKIP);
}
perror("munlock()");
goto unmap;
Expand Down Expand Up @@ -457,7 +459,7 @@ static int test_lock_onfault_of_present()
if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
if (errno == ENOSYS) {
printf("Cannot call new mlock family, skipping test\n");
_exit(0);
_exit(KSFT_SKIP);
}
perror("mlock2(MLOCK_ONFAULT)");
goto unmap;
Expand Down Expand Up @@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock)
if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) {
if (errno == ENOSYS) {
printf("Cannot call new mlock family, skipping test\n");
_exit(0);
_exit(KSFT_SKIP);
}
perror("mlock(ONFAULT)\n");
goto out;
Expand Down
5 changes: 4 additions & 1 deletion tools/testing/selftests/vm/run_vmtests
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# SPDX-License-Identifier: GPL-2.0
#please run as root

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

mnt=./huge
exitcode=0

Expand Down Expand Up @@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
if [ $? -ne 0 ]; then
echo "Please run this test as root"
exit 1
exit $ksft_skip
fi
while read name size unit; do
if [ "$name" = "HugePages_Free:" ]; then
Expand Down
4 changes: 3 additions & 1 deletion tools/testing/selftests/vm/userfaultfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
#include <setjmp.h>
#include <stdbool.h>

#include "../kselftest.h"

#ifdef __NR_userfaultfd

static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
Expand Down Expand Up @@ -1322,7 +1324,7 @@ int main(int argc, char **argv)
int main(void)
{
printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
return 0;
return KSFT_SKIP;
}

#endif /* __NR_userfaultfd */
5 changes: 4 additions & 1 deletion tools/testing/selftests/zram/zram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# SPDX-License-Identifier: GPL-2.0
TCID="zram.sh"

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

. ./zram_lib.sh

run_zram () {
Expand All @@ -24,5 +27,5 @@ elif [ -b /dev/zram0 ]; then
else
echo "$TCID : No zram.ko module or /dev/zram0 device file not found"
echo "$TCID : CONFIG_ZRAM is not set"
exit 1
exit $ksft_skip
fi
5 changes: 4 additions & 1 deletion tools/testing/selftests/zram/zram_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ MODULE=0
dev_makeswap=-1
dev_mounted=-1

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

trap INT

check_prereqs()
Expand All @@ -27,7 +30,7 @@ check_prereqs()

if [ $uid -ne 0 ]; then
echo $msg must be run as root >&2
exit 0
exit $ksft_skip
fi
}

Expand Down

0 comments on commit b13fbe7

Please sign in to comment.