Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-next-5.20-rc1' of git://git.kernel.org/pub…
Browse files Browse the repository at this point in the history
…/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest updates from Shuah Khan:

 - timers test build fixes and cleanups for new tool chains

 - removing khdr from kselftest framework and main Makefile

 - changes to test output messages to improve reports

* tag 'linux-kselftest-next-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (24 commits)
  Makefile: replace headers_install with headers for kselftest
  selftests/landlock: drop deprecated headers dependency
  selftests: timers: clocksource-switch: adapt to kselftest framework
  selftests: timers: clocksource-switch: add 'runtime' command line parameter
  selftests: timers: clocksource-switch: add command line switch to skip sanity check
  selftests: timers: clocksource-switch: sort includes
  selftests: timers: clocksource-switch: fix passing errors from child
  selftests: timers: inconsistency-check: adapt to kselftest framework
  selftests: timers: nanosleep: adapt to kselftest framework
  selftests: timers: fix declarations of main()
  selftests: timers: valid-adjtimex: build fix for newer toolchains
  Makefile: add headers_install to kselftest targets
  selftests: drop KSFT_KHDR_INSTALL make target
  selftests: stop using KSFT_KHDR_INSTALL
  selftests: drop khdr make target
  selftests: drivers/dma-buf: Improve message in selftest summary
  selftests/kcmp: Make the test output consistent and clear
  selftests:timers: globals don't need initialization to 0
  selftests/drivers/gpu: Add error messages to drm_mm.sh
  selftests/tpm2: increase timeout for kselftests
  ...
  • Loading branch information
torvalds committed Aug 3, 2022
2 parents 665fe72 + 4062eba commit e05d5b9
Show file tree
Hide file tree
Showing 30 changed files with 111 additions and 145 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,10 @@ tools/%: FORCE
# Kernel selftest

PHONY += kselftest
kselftest:
kselftest: headers
$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests

kselftest-%: FORCE
kselftest-%: headers FORCE
$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*

PHONY += kselftest-merge
Expand Down
30 changes: 3 additions & 27 deletions tools/testing/selftests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,38 +143,14 @@ endif
# Prepare for headers install
include $(top_srcdir)/scripts/subarch.include
ARCH ?= $(SUBARCH)
export KSFT_KHDR_INSTALL_DONE := 1
export BUILD
export KHDR_INCLUDES

# set default goal to all, so make without a target runs all, even when
# all isn't the first target in the file.
.DEFAULT_GOAL := all

# Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE
# is used to avoid running headers_install from lib.mk.
# Invoke headers install with --no-builtin-rules to avoid circular
# dependency in "make kselftest" case. In this case, second level
# make inherits builtin-rules which will use the rule generate
# Makefile.o and runs into
# "Circular Makefile.o <- prepare dependency dropped."
# and headers_install fails and test compile fails.
#
# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile
# invokes them as sub-makes and --no-builtin-rules is not necessary,
# but doesn't cause any failures. Keep it simple and use the same
# flags in both cases.
# Local build cases: "make kselftest", "make -C" - headers are installed
# in the default INSTALL_HDR_PATH usr/include.
khdr:
ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
else
$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(abs_objtree)/usr \
ARCH=$(ARCH) -C $(top_srcdir) headers_install
endif

all: khdr
all:
@ret=1; \
for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
Expand Down Expand Up @@ -253,7 +229,7 @@ ifdef INSTALL_PATH
for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
[ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \
echo -n "Emit Tests for $$TARGET\n"; \
echo -ne "Emit Tests for $$TARGET\n"; \
$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
-C $$TARGET emit_tests >> $(TEST_LIST); \
done;
Expand All @@ -274,4 +250,4 @@ clean:
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
done;

.PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
.PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar
1 change: 0 additions & 1 deletion tools/testing/selftests/arm64/mte/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ifeq ($(mte_cc_support),1)
TEST_GEN_PROGS := $(PROGS)

# Get Kernel headers installed and use them.
KSFT_KHDR_INSTALL := 1
else
$(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
$(warning test program "mte" will not be created.)
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/arm64/signal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ PROGS := $(patsubst %.c,%,$(SRCS))
TEST_GEN_PROGS := $(notdir $(PROGS))

# Get Kernel headers installed and use them.
KSFT_KHDR_INSTALL := 1

# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
# to account for any OUTPUT target-dirs optionally provided by
Expand Down
4 changes: 1 addition & 3 deletions tools/testing/selftests/arm64/signal/test_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include <ucontext.h>

/*
* Using ARCH specific and sanitized Kernel headers installed by KSFT
* framework since we asked for it by setting flag KSFT_KHDR_INSTALL
* in our Makefile.
* Using ARCH specific and sanitized Kernel headers from the tree.
*/
#include <asm/ptrace.h>
#include <asm/hwcap.h>
Expand Down
10 changes: 10 additions & 0 deletions tools/testing/selftests/damon/_chk_dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ do
exit 1
fi
done

permission_error="Operation not permitted"
for f in attrs target_ids monitor_on
do
status=$( cat "$DBGFS/$f" 2>&1 )
if [ "${status#*$permission_error}" != "$status" ]; then
echo "Permission for reading $DBGFS/$f denied; maybe secureboot enabled?"
exit $ksft_skip
fi
done
3 changes: 2 additions & 1 deletion tools/testing/selftests/drivers/dma-buf/udmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ int main(int argc, char *argv[])

devfd = open("/dev/udmabuf", O_RDWR);
if (devfd < 0) {
printf("%s: [skip,no-udmabuf]\n", TEST_PREFIX);
printf("%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n",
TEST_PREFIX);
exit(77);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/drivers/gpu/drm_mm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Runs API tests for struct drm_mm (DRM range manager)

if ! /sbin/modprobe -n -q test-drm_mm; then
echo "drivers/gpu/drm_mm: [skip]"
echo "drivers/gpu/drm_mm: module test-drm_mm is not found in /lib/modules/`uname -r` [skip]"
exit 77
fi

if /sbin/modprobe -q test-drm_mm; then
/sbin/modprobe -q -r test-drm_mm
echo "drivers/gpu/drm_mm: ok"
else
echo "drivers/gpu/drm_mm: [FAIL]"
echo "drivers/gpu/drm_mm: module test-drm_mm could not be removed [FAIL]"
exit 1
fi
1 change: 0 additions & 1 deletion tools/testing/selftests/drivers/s390x/uvdevice/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ else
TEST_GEN_PROGS := test_uvdevice

top_srcdir ?= ../../../../../..
KSFT_KHDR_INSTALL := 1
khdr_dir = $(top_srcdir)/usr/include
LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include

Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/futex/functional/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ TEST_GEN_FILES := \
TEST_PROGS := run.sh

top_srcdir = ../../../../..
KSFT_KHDR_INSTALL := 1
DEFAULT_INSTALL_HDR_PATH := 1
include ../../lib.mk

Expand Down
6 changes: 4 additions & 2 deletions tools/testing/selftests/kcmp/kcmp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ int main(int argc, char **argv)
int pid2 = getpid();
int ret;

ksft_print_header();
ksft_set_plan(3);

fd2 = open(kpath, O_RDWR, 0644);
if (fd2 < 0) {
perror("Can't open file");
Expand Down Expand Up @@ -152,7 +155,6 @@ int main(int argc, char **argv)
ksft_inc_pass_cnt();
}

ksft_print_cnts();

if (ret)
ksft_exit_fail();
Expand All @@ -162,5 +164,5 @@ int main(int argc, char **argv)

waitpid(pid2, &status, P_ALL);

return ksft_exit_pass();
return 0;
}
2 changes: 1 addition & 1 deletion tools/testing/selftests/kselftest_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ echo " main Makefile when optional -p is specified."
echo "- Prints pass/fail dependency check for each tests/sub-test."
echo "- Prints pass/fail targets and libraries."
echo "- Default: runs dependency checks on all tests."
echo "- Optional test name can be specified to check dependencies for it."
echo "- Optional: test name can be specified to check dependencies for it."
exit 1

}
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/kvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include ../../../build/Build.include
all:

top_srcdir = ../../../..
KSFT_KHDR_INSTALL := 1

# For cross-builds to work, UNAME_M has to map to ARCH and arch specific
# directories and targets in this Makefile. "uname -m" doesn't map to
Expand Down
10 changes: 2 additions & 8 deletions tools/testing/selftests/landlock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ TEST_GEN_PROGS := $(src_test:.c=)

TEST_GEN_PROGS_EXTENDED := true

KSFT_KHDR_INSTALL := 1
OVERRIDE_TARGETS := 1
include ../lib.mk

khdr_dir = $(top_srcdir)/usr/include

$(khdr_dir)/linux/landlock.h: khdr
@:

$(OUTPUT)/true: true.c
$(LINK.c) $< $(LDLIBS) -o $@ -static

$(OUTPUT)/%_test: %_test.c $(khdr_dir)/linux/landlock.h ../kselftest_harness.h common.h
$(LINK.c) $< $(LDLIBS) -o $@ -lcap -I$(khdr_dir)
$(OUTPUT)/%_test: %_test.c ../kselftest_harness.h common.h
$(LINK.c) $< $(LDLIBS) -o $@ -lcap
38 changes: 0 additions & 38 deletions tools/testing/selftests/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))

ifdef KSFT_KHDR_INSTALL
top_srcdir ?= ../../../..
include $(top_srcdir)/scripts/subarch.include
ARCH ?= $(SUBARCH)

# set default goal to all, so make without a target runs all, even when
# all isn't the first target in the file.
.DEFAULT_GOAL := all

# Invoke headers install with --no-builtin-rules to avoid circular
# dependency in "make kselftest" case. In this case, second level
# make inherits builtin-rules which will use the rule generate
# Makefile.o and runs into
# "Circular Makefile.o <- prepare dependency dropped."
# and headers_install fails and test compile fails.
# O= KBUILD_OUTPUT cases don't run into this error, since main Makefile
# invokes them as sub-makes and --no-builtin-rules is not necessary,
# but doesn't cause any failures. Keep it simple and use the same
# flags in both cases.
# Note that the support to install headers from lib.mk is necessary
# when test Makefile is run directly with "make -C".
# When local build is done, headers are installed in the default
# INSTALL_HDR_PATH usr/include.
.PHONY: khdr
.NOTPARALLEL:
khdr:
ifndef KSFT_KHDR_INSTALL_DONE
ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
else
$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$OUTPUT/usr \
ARCH=$(ARCH) -C $(top_srcdir) headers_install
endif
endif

all: khdr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
else
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
endif

define RUN_TESTS
BASE_DIR="$(selfdir)"; \
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ TEST_GEN_FILES += io_uring_zerocopy_tx

TEST_FILES := settings

KSFT_KHDR_INSTALL := 1
include ../lib.mk

include bpf/Makefile
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/net/mptcp/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-2.0

top_srcdir = ../../../../..
KSFT_KHDR_INSTALL := 1

CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)

Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/tc-testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ top_srcdir = $(abspath ../../../..)
APIDIR := $(top_scrdir)/include/uapi
TEST_GEN_FILES = action.o

KSFT_KHDR_INSTALL := 1
include ../lib.mk

PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/timers/adjtick.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int check_tick_adj(long tickval)
return 0;
}

int main(int argv, char **argc)
int main(int argc, char **argv)
{
struct timespec raw;
long tick, max, interval, err;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/timers/alarmtimer-suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ long long timespec_sub(struct timespec a, struct timespec b)
return ret;
}

int final_ret = 0;
int final_ret;

void sigalarm(int signo)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/timers/change_skew.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int change_skew_test(int ppm)
}


int main(int argv, char **argc)
int main(int argc, char **argv)
{
struct timex tx;
int i, ret;
Expand Down
Loading

0 comments on commit e05d5b9

Please sign in to comment.