Skip to content

Commit 4c7b63a

Browse files
committed
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 ...
2 parents 9cbda1b + 61c2018 commit 4c7b63a

32 files changed

Lines changed: 875 additions & 220 deletions

‎tools/testing/selftests/.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
kselftest
21
gpiogpio-event-mon
32
gpiogpio-hammer
43
gpioinclude/

‎tools/testing/selftests/Makefile‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ override LDFLAGS =
7171
override MAKEFLAGS =
7272
endif
7373

74+
# Append kselftest to KBUILD_OUTPUT to avoid cluttering
75+
# KBUILD_OUTPUT with selftest objects and headers installed
76+
# by selftests Makefile or lib.mk.
7477
ifneq ($(KBUILD_SRC),)
7578
override LDFLAGS =
7679
endif
@@ -79,19 +82,13 @@ ifneq ($(O),)
7982
BUILD := $(O)
8083
else
8184
ifneq ($(KBUILD_OUTPUT),)
82-
BUILD := $(KBUILD_OUTPUT)
85+
BUILD := $(KBUILD_OUTPUT)/kselftest
8386
else
8487
BUILD := $(shell pwd)
8588
DEFAULT_INSTALL_HDR_PATH := 1
8689
endif
8790
endif
8891

89-
# KSFT_TAP_LEVEL is used from KSFT framework to prevent nested TAP header
90-
# printing from tests. Applicable to run_tests case where run_tests adds
91-
# TAP header prior running tests and when a test program invokes another
92-
# with system() call. Export it here to cover override RUN_TESTS defines.
93-
export KSFT_TAP_LEVEL=`echo 1`
94-
9592
# Prepare for headers install
9693
top_srcdir ?= ../../..
9794
include $(top_srcdir)/scripts/subarch.include
@@ -169,14 +166,22 @@ clean_hotplug:
169166
run_pstore_crash:
170167
make -C pstore run_crash
171168

172-
INSTALL_PATH ?= install
169+
# Use $BUILD as the default install root. $BUILD points to the
170+
# right output location for the following cases:
171+
# 1. output_dir=kernel_src
172+
# 2. a separate output directory is specified using O= KBUILD_OUTPUT
173+
# 3. a separate output directory is specified using KBUILD_OUTPUT
174+
#
175+
INSTALL_PATH ?= $(BUILD)/install
173176
INSTALL_PATH := $(abspath $(INSTALL_PATH))
174177
ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
175178

176-
install:
179+
install: all
177180
ifdef INSTALL_PATH
178181
@# Ask all targets to install their files
179-
mkdir -p $(INSTALL_PATH)
182+
mkdir -p $(INSTALL_PATH)/kselftest
183+
install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/
184+
install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
180185
@for TARGET in $(TARGETS); do \
181186
BUILD_TARGET=$$BUILD/$$TARGET; \
182187
make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
@@ -186,24 +191,20 @@ ifdef INSTALL_PATH
186191
echo "#!/bin/sh" > $(ALL_SCRIPT)
187192
echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
188193
echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
194+
echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT)
189195
echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
190196
echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
191-
echo " OUTPUT=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
192-
echo " cat /dev/null > \$$OUTPUT" >> $(ALL_SCRIPT)
193-
echo "else" >> $(ALL_SCRIPT)
194-
echo " OUTPUT=/dev/stdout" >> $(ALL_SCRIPT)
197+
echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
198+
echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT)
195199
echo "fi" >> $(ALL_SCRIPT)
196-
echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
197-
echo "export skip=4" >> $(ALL_SCRIPT)
198200

199201
for TARGET in $(TARGETS); do \
200202
BUILD_TARGET=$$BUILD/$$TARGET; \
201-
echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT); \
202-
echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
203-
echo "echo ========================================" >> $(ALL_SCRIPT); \
204203
echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
205204
echo "cd $$TARGET" >> $(ALL_SCRIPT); \
205+
echo -n "run_many" >> $(ALL_SCRIPT); \
206206
make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
207+
echo "" >> $(ALL_SCRIPT); \
207208
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
208209
done;
209210

‎tools/testing/selftests/breakpoints/breakpoint_test.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "../kselftest.h"
2323

24+
#define COUNT_ISN_BPS 4
25+
#define COUNT_WPS 4
2426

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

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

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

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

338+
tests += 3 * COUNT_ISN_BPS;
339+
tests += sizeof(long) / 2 * 3 * COUNT_WPS;
340+
tests += sizeof(long) / 2 * 3 * COUNT_WPS;
341+
tests += 2;
342+
ksft_set_plan(tests);
343+
335344
/* Instruction breakpoints */
336345
for (local = 0; local < 2; local++) {
337346
for (global = 0; global < 2; global++) {

‎tools/testing/selftests/breakpoints/breakpoint_test_arm64.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
118118
return false;
119119
}
120120

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

216216
ksft_print_header();
217+
ksft_set_plan(213);
217218

218219
act.sa_handler = sigalrm;
219220
sigemptyset(&act.sa_mask);

‎tools/testing/selftests/breakpoints/step_after_suspend_test.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ int main(int argc, char **argv)
173173
int opt;
174174
bool do_suspend = true;
175175
bool succeeded = true;
176+
unsigned int tests = 0;
176177
cpu_set_t available_cpus;
177178
int err;
178179
int cpu;
@@ -191,6 +192,13 @@ int main(int argc, char **argv)
191192
}
192193
}
193194

195+
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
196+
if (!CPU_ISSET(cpu, &available_cpus))
197+
continue;
198+
tests++;
199+
}
200+
ksft_set_plan(tests);
201+
194202
if (do_suspend)
195203
suspend();
196204

‎tools/testing/selftests/capabilities/test_execve.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ int main(int argc, char **argv)
430430
{
431431
char *tmp1, *tmp2, *our_path;
432432

433-
ksft_print_header();
434-
435433
/* Find our path */
436434
tmp1 = strdup(argv[0]);
437435
if (!tmp1)
@@ -445,13 +443,17 @@ int main(int argc, char **argv)
445443
mpid = getpid();
446444

447445
if (fork_wait()) {
446+
ksft_print_header();
447+
ksft_set_plan(12);
448448
ksft_print_msg("[RUN]\t+++ Tests with uid == 0 +++\n");
449449
return do_tests(0, our_path);
450450
}
451451

452452
ksft_print_msg("==================================================\n");
453453

454454
if (fork_wait()) {
455+
ksft_print_header();
456+
ksft_set_plan(9);
455457
ksft_print_msg("[RUN]\t+++ Tests with uid != 0 +++\n");
456458
return do_tests(1, our_path);
457459
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dma-buf/udmabuf

‎tools/testing/selftests/futex/functional/futex_requeue_pi.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ int main(int argc, char *argv[])
395395
}
396396

397397
ksft_print_header();
398+
ksft_set_plan(1);
398399
ksft_print_msg("%s: Test requeue functionality\n", basename(argv[0]));
399400
ksft_print_msg(
400401
"\tArguments: broadcast=%d locked=%d owner=%d timeout=%ldns\n",

‎tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ int main(int argc, char *argv[])
7979
}
8080

8181
ksft_print_header();
82+
ksft_set_plan(1);
8283
ksft_print_msg("%s: Detect mismatched requeue_pi operations\n",
8384
basename(argv[0]));
8485

‎tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ int main(int argc, char *argv[])
144144
}
145145

146146
ksft_print_header();
147+
ksft_set_plan(1);
147148
ksft_print_msg("%s: Test signal handling during requeue_pi\n",
148149
basename(argv[0]));
149150
ksft_print_msg("\tArguments: <none>\n");

0 commit comments

Comments
 (0)