linux-kselftest-next-5.20-rc1

This Kselftest update for Linux 5.20-rc1 consists of:
 
 - 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAmLoSY4ACgkQCwJExA0N
 QxyukA//WMYoc9QfVNlBX+XHWqUy+XIP8GLiq08Bq4Ir7a+yZI7AIksnogb9rLZV
 Nhm+MGjk0DoIRrz8RFK3lpXparUZEb/H/aye329Sn+v/ICh9i2AWfv01S3vu5NB8
 5eYxF0LGHZnVWi9ttesUoNsFmJ2jeD3IAbD1KOZTzq5KALvfbgckl4bRbbE65YFS
 kxDfSgPmYV+2qXkZKi6B3kB0+oihi/jQdfdr3rdxRLRAxTlOH4RqIHS80m9itjWr
 bDA+RYMS/BuumAMCGokPhRFkt82EQPY2SsbPBb6d1v5mF3j+3Fboyj/UwwNM1sJZ
 sfZD3/xZZMpNI3eFKTjYmd4TYbcPUpGudE4YDme64ITvRYlfErWsztCheeZzRPte
 0HUaO5JEYKtD/a6bFnTJVksXy6w8wPjvy2JwqK5IMkBMl5wNPZFNdCSiM4rOpiA2
 LXyrkeCJ59Tilf7VU/FbhEKXogI0FZK8T7WEPBe3+kARlwJQbQijmGVdutM1S5QT
 A1UKyfUNMTm12cgLEX4Lfcb0JJQn6IXMfp9XKqbrAjEH0tNmCqolcL9Cci9tdU+6
 XkFdAUO/xRBS+7/HSsdbMWaKCWx0FG4VLW9E2o2+Js26c+pUwJRThN1yox+kAWm2
 BcVHxskmjjAgYvL+0eB+tNCe8vImSmgyQhnEcxYlv3CTWDtLoQ4=
 =sFMu
 -----END PGP SIGNATURE-----

Merge tag 'linux-kselftest-next-5.20-rc1' of git://git.kernel.org/pub/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
  ...
This commit is contained in:
Linus Torvalds 2022-08-02 19:44:56 -07:00
commit e05d5b9c5b
30 changed files with 111 additions and 145 deletions

View File

@ -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

View File

@ -143,7 +143,6 @@ endif
# Prepare for headers install
include $(top_srcdir)/scripts/subarch.include
ARCH ?= $(SUBARCH)
export KSFT_KHDR_INSTALL_DONE := 1
export BUILD
export KHDR_INCLUDES
@ -151,30 +150,7 @@ export KHDR_INCLUDES
# 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; \
@ -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;
@ -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

View File

@ -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.)

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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);
}

View File

@ -3,7 +3,7 @@
# 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
@ -11,6 +11,6 @@ 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

View File

@ -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

View File

@ -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

View File

@ -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");
@ -152,7 +155,6 @@ int main(int argc, char **argv)
ksft_inc_pass_cnt();
}
ksft_print_cnts();
if (ret)
ksft_exit_fail();
@ -162,5 +164,5 @@ int main(int argc, char **argv)
waitpid(pid2, &status, P_ALL);
return ksft_exit_pass();
return 0;
}

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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)"; \

View File

@ -63,7 +63,6 @@ TEST_GEN_FILES += io_uring_zerocopy_tx
TEST_FILES := settings
KSFT_KHDR_INSTALL := 1
include ../lib.mk
include bpf/Makefile

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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)
{

View File

@ -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;

View File

@ -23,17 +23,17 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include "../kselftest.h"
@ -110,21 +110,40 @@ int run_tests(int secs)
sprintf(buf, "./inconsistency-check -t %i", secs);
ret = system(buf);
if (ret)
return ret;
if (WIFEXITED(ret) && WEXITSTATUS(ret))
return WEXITSTATUS(ret);
ret = system("./nanosleep");
return ret;
return WIFEXITED(ret) ? WEXITSTATUS(ret) : 0;
}
char clocksource_list[10][30];
int main(int argv, char **argc)
int main(int argc, char **argv)
{
char orig_clk[512];
int count, i, status;
int count, i, status, opt;
int do_sanity_check = 1;
int runtime = 60;
pid_t pid;
/* Process arguments */
while ((opt = getopt(argc, argv, "st:")) != -1) {
switch (opt) {
case 's':
do_sanity_check = 0;
break;
case 't':
runtime = atoi(optarg);
break;
default:
printf("Usage: %s [-s] [-t <secs>]\n", argv[0]);
printf(" -s: skip sanity checks\n");
printf(" -t: Number of seconds to run\n");
exit(-1);
}
}
get_cur_clocksource(orig_clk, 512);
count = get_clocksources(clocksource_list);
@ -135,23 +154,25 @@ int main(int argv, char **argc)
}
/* Check everything is sane before we start switching asynchronously */
for (i = 0; i < count; i++) {
printf("Validating clocksource %s\n", clocksource_list[i]);
if (change_clocksource(clocksource_list[i])) {
status = -1;
goto out;
}
if (run_tests(5)) {
status = -1;
goto out;
if (do_sanity_check) {
for (i = 0; i < count; i++) {
printf("Validating clocksource %s\n",
clocksource_list[i]);
if (change_clocksource(clocksource_list[i])) {
status = -1;
goto out;
}
if (run_tests(5)) {
status = -1;
goto out;
}
}
}
printf("Running Asynchronous Switching Tests...\n");
pid = fork();
if (!pid)
return run_tests(60);
return run_tests(runtime);
while (pid != waitpid(pid, &status, WNOHANG))
for (i = 0; i < count; i++)
@ -162,7 +183,9 @@ int main(int argv, char **argc)
out:
change_clocksource(orig_clk);
if (status)
return ksft_exit_fail();
return ksft_exit_pass();
/* Print at the end to not mix output with child process */
ksft_print_header();
ksft_set_plan(1);
ksft_test_result(!status, "clocksource-switch\n");
ksft_exit(!status);
}

View File

@ -122,30 +122,28 @@ int consistency_test(int clock_type, unsigned long seconds)
if (inconsistent >= 0) {
unsigned long long delta;
printf("\%s\n", start_str);
ksft_print_msg("\%s\n", start_str);
for (i = 0; i < CALLS_PER_LOOP; i++) {
if (i == inconsistent)
printf("--------------------\n");
printf("%lu:%lu\n", list[i].tv_sec,
ksft_print_msg("--------------------\n");
ksft_print_msg("%lu:%lu\n", list[i].tv_sec,
list[i].tv_nsec);
if (i == inconsistent + 1)
printf("--------------------\n");
ksft_print_msg("--------------------\n");
}
delta = list[inconsistent].tv_sec * NSEC_PER_SEC;
delta += list[inconsistent].tv_nsec;
delta -= list[inconsistent+1].tv_sec * NSEC_PER_SEC;
delta -= list[inconsistent+1].tv_nsec;
printf("Delta: %llu ns\n", delta);
ksft_print_msg("Delta: %llu ns\n", delta);
fflush(0);
/* timestamp inconsistency*/
t = time(0);
printf("%s\n", ctime(&t));
printf("[FAILED]\n");
ksft_print_msg("%s\n", ctime(&t));
return -1;
}
now = list[0].tv_sec;
}
printf("[OK]\n");
return 0;
}
@ -178,16 +176,22 @@ int main(int argc, char *argv[])
setbuf(stdout, NULL);
ksft_print_header();
ksft_set_plan(maxclocks - userclock);
for (clockid = userclock; clockid < maxclocks; clockid++) {
if (clockid == CLOCK_HWSPECIFIC)
if (clockid == CLOCK_HWSPECIFIC || clock_gettime(clockid, &ts)) {
ksft_test_result_skip("%-31s\n", clockstring(clockid));
continue;
}
if (!clock_gettime(clockid, &ts)) {
printf("Consistent %-30s ", clockstring(clockid));
if (consistency_test(clockid, runtime))
return ksft_exit_fail();
if (consistency_test(clockid, runtime)) {
ksft_test_result_fail("%-31s\n", clockstring(clockid));
ksft_exit_fail();
} else {
ksft_test_result_pass("%-31s\n", clockstring(clockid));
}
}
return ksft_exit_pass();
ksft_exit_pass();
}

View File

@ -133,33 +133,37 @@ int main(int argc, char **argv)
long long length;
int clockid, ret;
ksft_print_header();
ksft_set_plan(NR_CLOCKIDS);
for (clockid = CLOCK_REALTIME; clockid < NR_CLOCKIDS; clockid++) {
/* Skip cputime clockids since nanosleep won't increment cputime */
if (clockid == CLOCK_PROCESS_CPUTIME_ID ||
clockid == CLOCK_THREAD_CPUTIME_ID ||
clockid == CLOCK_HWSPECIFIC)
clockid == CLOCK_HWSPECIFIC) {
ksft_test_result_skip("%-31s\n", clockstring(clockid));
continue;
}
printf("Nanosleep %-31s ", clockstring(clockid));
fflush(stdout);
length = 10;
while (length <= (NSEC_PER_SEC * 10)) {
ret = nanosleep_test(clockid, length);
if (ret == UNSUPPORTED) {
printf("[UNSUPPORTED]\n");
ksft_test_result_skip("%-31s\n", clockstring(clockid));
goto next;
}
if (ret < 0) {
printf("[FAILED]\n");
return ksft_exit_fail();
ksft_test_result_fail("%-31s\n", clockstring(clockid));
ksft_exit_fail();
}
length *= 100;
}
printf("[OK]\n");
ksft_test_result_pass("%-31s\n", clockstring(clockid));
next:
ret = 0;
}
return ksft_exit_pass();
ksft_exit_pass();
}

View File

@ -89,7 +89,7 @@ void get_monotonic_and_raw(struct timespec *mon, struct timespec *raw)
}
}
int main(int argv, char **argc)
int main(int argc, char **argv)
{
struct timespec mon, raw, start, end;
long long delta1, delta2, interval, eppm, ppm;

View File

@ -38,7 +38,7 @@
#define NSEC_PER_SEC 1000000000LL
int main(int argv, char **argc)
int main(int argc, char **argv)
{
struct timex tx;
int ret, ppm;

View File

@ -40,7 +40,7 @@
#define ADJ_SETOFFSET 0x0100
#include <sys/syscall.h>
static int clock_adjtime(clockid_t id, struct timex *tx)
int clock_adjtime(clockid_t id, struct timex *tx)
{
return syscall(__NR_clock_adjtime, id, tx);
}

View File

@ -0,0 +1 @@
timeout=600

View File

@ -94,7 +94,6 @@ TEST_PROGS := run_vmtests.sh
TEST_FILES := test_vmalloc.sh
TEST_FILES += test_hmm.sh
KSFT_KHDR_INSTALL := 1
include ../lib.mk
$(OUTPUT)/madv_populate: vm_util.c

View File

@ -860,7 +860,7 @@ static int stress(struct uffd_stats *uffd_stats)
/*
* Be strict and immediately zap area_src, the whole area has
* been transferred already by the background treads. The
* area_src could then be faulted in in a racy way by still
* area_src could then be faulted in a racy way by still
* running uffdio_threads reading zeropages after we zapped
* area_src (but they're guaranteed to get -EEXIST from
* UFFDIO_COPY without writing zero pages into area_dst