Commit 4c7b63a3 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'linux-kselftest-5.2-rc1-2' of...

Merge tag 'linux-kselftest-5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull more kselftest updates from Shuah Khan:

 - kselftest framework bpf build/test workflow regression fix

 - Fix to kselftest install to use default install path

 - Fix to kselftest KBUILD_OUTPUT builds to not clutter main
   KBUILD_OUTPUT directory with selftest objects

 - .gitignore fixes (Kelsey Skunberg)

 - rseq selftests updates (Mathieu Desnoyers and Martin Schwidefsky)

   They change the per-architecture pre-abort signatures to ensure those
   are valid trap instructions.

   The way exit points are presented to debuggers is enhanced, ensuring
   all exit points are present, so debuggers don't have to disassemble
   rseq critical section to properly skip over them.

   Discussions with the glibc community is reaching a consensus of
   exposing a __rseq_handled symbol from glibc to coexist with rseq
   early adopters. Update the rseq selftest code to expose and use this
   symbol.

   Support for compiling asm goto with clang is added with the
   "-no-integrated-as" compiler switch, similarly to the top level
   kernel Makefile.

 - kselftest Makefile test run output refactoring and making test output
   TAP13 compliant from Kees Cook:

   This re-factors the selftest Makefiles to extract the test running
   logic to be reused between "run_tests" and "emit_tests", while also
   fixing up the test output to be TAP version 13 compliant:
	- added "plan" line
	- fixed result line syntax
	- moved all test output to be "# "-prefixed as TAP "diagnostic"
	  lines

   The prefixing code includes a fallback mode for limited execution
   environments.

   Additionally, the plan lines are fixed for all callers of
   kselftest.h.

* tag 'linux-kselftest-5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (25 commits)
  selftests: avoid KBUILD_OUTPUT dir cluttering with selftest objects
  selftests: drivers: Create .gitignore to include /dma-buf/udmabuf
  selftests: pidfd: Create .gitignore to include pidfd_test
  selftests: fix bpf build/test workflow regression when KBUILD_OUTPUT is set
  selftests: fix install target to use default install path
  rseq/selftests: add -no-integrated-as for clang
  rseq/selftests: mips: use break instruction for RSEQ_SIG
  rseq/selftests: powerpc code signature: generate valid instructions
  rseq/selftests: aarch64 code signature: handle big-endian environment
  rseq/selftests: arm: use udf instruction for RSEQ_SIG
  rseq/selftests: s390: use trap4 for RSEQ_SIG
  rseq/selftests: x86: use ud1 instruction as RSEQ_SIG opcode
  rseq/selftests: s390: use jg instruction for jumps outside of the asm
  rseq/selftests: Use __rseq_handled symbol to coexist with glibc
  rseq/selftests: Introduce __rseq_cs_ptr_array, rename __rseq_table to __rseq_cs
  rseq/selftests: Add __rseq_exit_point_array section for debuggers
  rseq/selftests: x86: Work-around bogus gcc-8 optimisation
  selftests: Add test plan API to kselftest.h and adjust callers
  selftests: Remove KSFT_TAP_LEVEL
  selftests: Move test output to diagnostic lines
  ...
parents 9cbda1bd 61c2018c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
kselftest
gpiogpio-event-mon
gpiogpio-hammer
gpioinclude/
+20 −19
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ override LDFLAGS =
override MAKEFLAGS =
endif

# Append kselftest to KBUILD_OUTPUT to avoid cluttering
# KBUILD_OUTPUT with selftest objects and headers installed
# by selftests Makefile or lib.mk.
ifneq ($(KBUILD_SRC),)
override LDFLAGS =
endif
@@ -79,19 +82,13 @@ ifneq ($(O),)
	BUILD := $(O)
else
	ifneq ($(KBUILD_OUTPUT),)
		BUILD := $(KBUILD_OUTPUT)
		BUILD := $(KBUILD_OUTPUT)/kselftest
	else
		BUILD := $(shell pwd)
		DEFAULT_INSTALL_HDR_PATH := 1
	endif
endif

# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
# printing from tests. Applicable to run_tests case where run_tests adds
# TAP header prior running tests and when a test program invokes another
# with system() call. Export it here to cover override RUN_TESTS defines.
export KSFT_TAP_LEVEL=`echo 1`

# Prepare for headers install
top_srcdir ?= ../../..
include $(top_srcdir)/scripts/subarch.include
@@ -169,14 +166,22 @@ clean_hotplug:
run_pstore_crash:
	make -C pstore run_crash

INSTALL_PATH ?= install
# Use $BUILD as the default install root. $BUILD points to the
# right output location for the following cases:
# 1. output_dir=kernel_src
# 2. a separate output directory is specified using O= KBUILD_OUTPUT
# 3. a separate output directory is specified using KBUILD_OUTPUT
#
INSTALL_PATH ?= $(BUILD)/install
INSTALL_PATH := $(abspath $(INSTALL_PATH))
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh

install:
install: all
ifdef INSTALL_PATH
	@# Ask all targets to install their files
	mkdir -p $(INSTALL_PATH)
	mkdir -p $(INSTALL_PATH)/kselftest
	install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/
	install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
	@for TARGET in $(TARGETS); do \
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
@@ -186,24 +191,20 @@ ifdef INSTALL_PATH
	echo "#!/bin/sh" > $(ALL_SCRIPT)
	echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
	echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
	echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT)
	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
	echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
	echo "  OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
	echo "  cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
	echo "else" >> $(ALL_SCRIPT)
	echo "  OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
	echo "  logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
	echo "  cat /dev/null > \$$logfile" >> $(ALL_SCRIPT)
	echo "fi" >> $(ALL_SCRIPT)
	echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
	echo "export skip=4" >> $(ALL_SCRIPT)

	for TARGET in $(TARGETS); do \
		BUILD_TARGET=$$BUILD/$$TARGET;	\
		echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT);	\
		echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
		echo "echo ========================================" >> $(ALL_SCRIPT); \
		echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
		echo -n "run_many" >> $(ALL_SCRIPT); \
		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
		echo "" >> $(ALL_SCRIPT);	    \
		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
	done;

+12 −3
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

#include "../kselftest.h"

#define COUNT_ISN_BPS	4
#define COUNT_WPS	4

/* Breakpoint access modes */
enum {
@@ -220,7 +222,7 @@ static void trigger_tests(void)
			if (!local && !global)
				continue;

			for (i = 0; i < 4; i++) {
			for (i = 0; i < COUNT_ISN_BPS; i++) {
				dummy_funcs[i]();
				check_trapped();
			}
@@ -292,7 +294,7 @@ static void launch_instruction_breakpoints(char *buf, int local, int global)
{
	int i;

	for (i = 0; i < 4; i++) {
	for (i = 0; i < COUNT_ISN_BPS; i++) {
		set_breakpoint_addr(dummy_funcs[i], i);
		toggle_breakpoint(i, BP_X, 1, local, global, 1);
		ptrace(PTRACE_CONT, child_pid, NULL, 0);
@@ -314,7 +316,7 @@ static void launch_watchpoints(char *buf, int mode, int len,
	else
		mode_str = "read";

	for (i = 0; i < 4; i++) {
	for (i = 0; i < COUNT_WPS; i++) {
		set_breakpoint_addr(&dummy_var[i], i);
		toggle_breakpoint(i, mode, len, local, global, 1);
		ptrace(PTRACE_CONT, child_pid, NULL, 0);
@@ -330,8 +332,15 @@ static void launch_watchpoints(char *buf, int mode, int len,
static void launch_tests(void)
{
	char buf[1024];
	unsigned int tests = 0;
	int len, local, global, i;

	tests += 3 * COUNT_ISN_BPS;
	tests += sizeof(long) / 2 * 3 * COUNT_WPS;
	tests += sizeof(long) / 2 * 3 * COUNT_WPS;
	tests += 2;
	ksft_set_plan(tests);

	/* Instruction breakpoints */
	for (local = 0; local < 2; local++) {
		for (global = 0; global < 2; global++) {
+2 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
	return false;
}

static bool run_test(int wr_size, int wp_size, int wr, int wp)
static bool arun_test(int wr_size, int wp_size, int wr, int wp)
{
	int status;
	siginfo_t siginfo;
@@ -214,6 +214,7 @@ int main(int argc, char **argv)
	bool result;

	ksft_print_header();
	ksft_set_plan(213);

	act.sa_handler = sigalrm;
	sigemptyset(&act.sa_mask);
+8 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ int main(int argc, char **argv)
	int opt;
	bool do_suspend = true;
	bool succeeded = true;
	unsigned int tests = 0;
	cpu_set_t available_cpus;
	int err;
	int cpu;
@@ -191,6 +192,13 @@ int main(int argc, char **argv)
		}
	}

	for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
		if (!CPU_ISSET(cpu, &available_cpus))
			continue;
		tests++;
	}
	ksft_set_plan(tests);

	if (do_suspend)
		suspend();

Loading