Skip to content

Commit 25b20ae

Browse files
committed
Merge tag 'linux-kselftest-fixes-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest fixes from Shuah Khan: "Important fixes to several tests and documentation clarification on running mainline kselftest on stable releases. A few notable fixes: - fix kselftest run hang due to child processes that haven't been terminated. Fix signals all child processes - fix false pass/fail results from vdso_test_abi, openat2, mincore - build failures when using -j (multiple jobs) option - exec test build failure due to incorrect build rule for a run-time created "pipe" - zram test fixes related to interaction with zram-generator to make sure zram test to coordinate deleted with zram-generator - zram test compression ratio calculation fix and skipping max_comp_streams. - increasing rtc test timeout - cpufreq test to write test results to stdout which will necessary on automated test systems" * tag 'linux-kselftest-fixes-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kselftest: Fix vdso_test_abi return status selftests: skip mincore.check_file_mmap when fs lacks needed support selftests: openat2: Skip testcases that fail with EOPNOTSUPP selftests: openat2: Add missing dependency in Makefile selftests: openat2: Print also errno in failure messages selftests: futex: Use variable MAKE instead of make selftests/exec: Remove pipe from TEST_GEN_FILES selftests/zram: Adapt the situation that /dev/zram0 is being used selftests/zram01.sh: Fix compression ratio calculation selftests/zram: Skip max_comp_streams interface on newer kernel docs/kselftest: clarify running mainline tests on stables kselftest: signal all child processes selftests: cpufreq: Write test output to stdout as well selftests: rtc: Increase test timeout so that all tests run
2 parents 1f2cfdd + ec04989 commit 25b20ae

File tree

15 files changed

+209
-177
lines changed

15 files changed

+209
-177
lines changed

Documentation/dev-tools/kselftest.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ directory. These are intended to be small tests to exercise individual code
77
paths in the kernel. Tests are intended to be run after building, installing
88
and booting a kernel.
99

10+
Kselftest from mainline can be run on older stable kernels. Running tests
11+
from mainline offers the best coverage. Several test rings run mainline
12+
kselftest suite on stable releases. The reason is that when a new test
13+
gets added to test existing code to regression test a bug, we should be
14+
able to run that test on an older kernel. Hence, it is important to keep
15+
code that can still test an older kernel and make sure it skips the test
16+
gracefully on newer releases.
17+
1018
You can find additional information on Kselftest framework, how to
1119
write new tests using the framework on Kselftest wiki:
1220

tools/testing/selftests/cpufreq/main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,5 @@ prerequisite
194194

195195
# Run requested functions
196196
clear_dumps $OUTFILE
197-
do_test >> $OUTFILE.txt
197+
do_test | tee -a $OUTFILE.txt
198198
dmesg_dumps $OUTFILE

tools/testing/selftests/exec/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CFLAGS += -D_GNU_SOURCE
55

66
TEST_PROGS := binfmt_script non-regular
77
TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216
8-
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir pipe
8+
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
99
# Makefile is a run-time dependency, since it's accessed by the execveat test
1010
TEST_FILES := Makefile
1111

tools/testing/selftests/futex/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ all:
1111
@for DIR in $(SUBDIRS); do \
1212
BUILD_TARGET=$(OUTPUT)/$$DIR; \
1313
mkdir $$BUILD_TARGET -p; \
14-
make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
14+
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
1515
if [ -e $$DIR/$(TEST_PROGS) ]; then \
1616
rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \
1717
fi \
@@ -32,6 +32,6 @@ override define CLEAN
3232
@for DIR in $(SUBDIRS); do \
3333
BUILD_TARGET=$(OUTPUT)/$$DIR; \
3434
mkdir $$BUILD_TARGET -p; \
35-
make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
35+
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
3636
done
3737
endef

tools/testing/selftests/kselftest_harness.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,8 @@ static void __timeout_handler(int sig, siginfo_t *info, void *ucontext)
877877
}
878878

879879
t->timed_out = true;
880-
kill(t->pid, SIGKILL);
880+
// signal process group
881+
kill(-(t->pid), SIGKILL);
881882
}
882883

883884
void __wait_for_test(struct __test_metadata *t)
@@ -987,6 +988,7 @@ void __run_test(struct __fixture_metadata *f,
987988
ksft_print_msg("ERROR SPAWNING TEST CHILD\n");
988989
t->passed = 0;
989990
} else if (t->pid == 0) {
991+
setpgrp();
990992
t->fn(t, variant);
991993
if (t->skip)
992994
_exit(255);

tools/testing/selftests/mincore/mincore_selftest.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,21 @@ TEST(check_file_mmap)
207207

208208
errno = 0;
209209
fd = open(".", O_TMPFILE | O_RDWR, 0600);
210-
ASSERT_NE(-1, fd) {
211-
TH_LOG("Can't create temporary file: %s",
212-
strerror(errno));
210+
if (fd < 0) {
211+
ASSERT_EQ(errno, EOPNOTSUPP) {
212+
TH_LOG("Can't create temporary file: %s",
213+
strerror(errno));
214+
}
215+
SKIP(goto out_free, "O_TMPFILE not supported by filesystem.");
213216
}
214217
errno = 0;
215218
retval = fallocate(fd, 0, 0, FILE_SIZE);
216-
ASSERT_EQ(0, retval) {
217-
TH_LOG("Error allocating space for the temporary file: %s",
218-
strerror(errno));
219+
if (retval) {
220+
ASSERT_EQ(errno, EOPNOTSUPP) {
221+
TH_LOG("Error allocating space for the temporary file: %s",
222+
strerror(errno));
223+
}
224+
SKIP(goto out_close, "fallocate not supported by filesystem.");
219225
}
220226

221227
/*
@@ -271,7 +277,9 @@ TEST(check_file_mmap)
271277
}
272278

273279
munmap(addr, FILE_SIZE);
280+
out_close:
274281
close(fd);
282+
out_free:
275283
free(vec);
276284
}
277285

tools/testing/selftests/openat2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test
55

66
include ../lib.mk
77

8-
$(TEST_GEN_PROGS): helpers.c
8+
$(TEST_GEN_PROGS): helpers.c helpers.h

tools/testing/selftests/openat2/helpers.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#define _GNU_SOURCE
1111
#include <stdint.h>
12+
#include <stdbool.h>
1213
#include <errno.h>
1314
#include <linux/types.h>
1415
#include "../kselftest.h"
@@ -62,11 +63,12 @@ bool needs_openat2(const struct open_how *how);
6263
(similar to chroot(2)). */
6364
#endif /* RESOLVE_IN_ROOT */
6465

65-
#define E_func(func, ...) \
66-
do { \
67-
if (func(__VA_ARGS__) < 0) \
68-
ksft_exit_fail_msg("%s:%d %s failed\n", \
69-
__FILE__, __LINE__, #func);\
66+
#define E_func(func, ...) \
67+
do { \
68+
errno = 0; \
69+
if (func(__VA_ARGS__) < 0) \
70+
ksft_exit_fail_msg("%s:%d %s failed - errno:%d\n", \
71+
__FILE__, __LINE__, #func, errno); \
7072
} while (0)
7173

7274
#define E_asprintf(...) E_func(asprintf, __VA_ARGS__)

tools/testing/selftests/openat2/openat2_test.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ void test_openat2_flags(void)
259259
unlink(path);
260260

261261
fd = sys_openat2(AT_FDCWD, path, &test->how);
262+
if (fd < 0 && fd == -EOPNOTSUPP) {
263+
/*
264+
* Skip the testcase if it failed because not supported
265+
* by FS. (e.g. a valid O_TMPFILE combination on NFS)
266+
*/
267+
ksft_test_result_skip("openat2 with %s fails with %d (%s)\n",
268+
test->name, fd, strerror(-fd));
269+
goto next;
270+
}
271+
262272
if (test->err >= 0)
263273
failed = (fd < 0);
264274
else
@@ -303,7 +313,7 @@ void test_openat2_flags(void)
303313
else
304314
resultfn("openat2 with %s fails with %d (%s)\n",
305315
test->name, test->err, strerror(-test->err));
306-
316+
next:
307317
free(fdpath);
308318
fflush(stdout);
309319
}

tools/testing/selftests/rtc/settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
timeout=90
1+
timeout=180

0 commit comments

Comments
 (0)