Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-fixes-5.17-rc3' of git://git.kernel.org/pu…
Browse files Browse the repository at this point in the history
…b/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
  • Loading branch information
Linus Torvalds committed Feb 4, 2022
2 parents 1f2cfdd + ec04989 commit 25b20ae
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 177 deletions.
8 changes: 8 additions & 0 deletions Documentation/dev-tools/kselftest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ directory. These are intended to be small tests to exercise individual code
paths in the kernel. Tests are intended to be run after building, installing
and booting a kernel.

Kselftest from mainline can be run on older stable kernels. Running tests
from mainline offers the best coverage. Several test rings run mainline
kselftest suite on stable releases. The reason is that when a new test
gets added to test existing code to regression test a bug, we should be
able to run that test on an older kernel. Hence, it is important to keep
code that can still test an older kernel and make sure it skips the test
gracefully on newer releases.

You can find additional information on Kselftest framework, how to
write new tests using the framework on Kselftest wiki:

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/cpufreq/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,5 @@ prerequisite

# Run requested functions
clear_dumps $OUTFILE
do_test >> $OUTFILE.txt
do_test | tee -a $OUTFILE.txt
dmesg_dumps $OUTFILE
2 changes: 1 addition & 1 deletion tools/testing/selftests/exec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CFLAGS += -D_GNU_SOURCE

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

Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/futex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ all:
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
if [ -e $$DIR/$(TEST_PROGS) ]; then \
rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \
fi \
Expand All @@ -32,6 +32,6 @@ override define CLEAN
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
done
endef
4 changes: 3 additions & 1 deletion tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,8 @@ static void __timeout_handler(int sig, siginfo_t *info, void *ucontext)
}

t->timed_out = true;
kill(t->pid, SIGKILL);
// signal process group
kill(-(t->pid), SIGKILL);
}

void __wait_for_test(struct __test_metadata *t)
Expand Down Expand Up @@ -987,6 +988,7 @@ void __run_test(struct __fixture_metadata *f,
ksft_print_msg("ERROR SPAWNING TEST CHILD\n");
t->passed = 0;
} else if (t->pid == 0) {
setpgrp();
t->fn(t, variant);
if (t->skip)
_exit(255);
Expand Down
20 changes: 14 additions & 6 deletions tools/testing/selftests/mincore/mincore_selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,21 @@ TEST(check_file_mmap)

errno = 0;
fd = open(".", O_TMPFILE | O_RDWR, 0600);
ASSERT_NE(-1, fd) {
TH_LOG("Can't create temporary file: %s",
strerror(errno));
if (fd < 0) {
ASSERT_EQ(errno, EOPNOTSUPP) {
TH_LOG("Can't create temporary file: %s",
strerror(errno));
}
SKIP(goto out_free, "O_TMPFILE not supported by filesystem.");
}
errno = 0;
retval = fallocate(fd, 0, 0, FILE_SIZE);
ASSERT_EQ(0, retval) {
TH_LOG("Error allocating space for the temporary file: %s",
strerror(errno));
if (retval) {
ASSERT_EQ(errno, EOPNOTSUPP) {
TH_LOG("Error allocating space for the temporary file: %s",
strerror(errno));
}
SKIP(goto out_close, "fallocate not supported by filesystem.");
}

/*
Expand Down Expand Up @@ -271,7 +277,9 @@ TEST(check_file_mmap)
}

munmap(addr, FILE_SIZE);
out_close:
close(fd);
out_free:
free(vec);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/openat2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test

include ../lib.mk

$(TEST_GEN_PROGS): helpers.c
$(TEST_GEN_PROGS): helpers.c helpers.h
12 changes: 7 additions & 5 deletions tools/testing/selftests/openat2/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#define _GNU_SOURCE
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <linux/types.h>
#include "../kselftest.h"
Expand Down Expand Up @@ -62,11 +63,12 @@ bool needs_openat2(const struct open_how *how);
(similar to chroot(2)). */
#endif /* RESOLVE_IN_ROOT */

#define E_func(func, ...) \
do { \
if (func(__VA_ARGS__) < 0) \
ksft_exit_fail_msg("%s:%d %s failed\n", \
__FILE__, __LINE__, #func);\
#define E_func(func, ...) \
do { \
errno = 0; \
if (func(__VA_ARGS__) < 0) \
ksft_exit_fail_msg("%s:%d %s failed - errno:%d\n", \
__FILE__, __LINE__, #func, errno); \
} while (0)

#define E_asprintf(...) E_func(asprintf, __VA_ARGS__)
Expand Down
12 changes: 11 additions & 1 deletion tools/testing/selftests/openat2/openat2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ void test_openat2_flags(void)
unlink(path);

fd = sys_openat2(AT_FDCWD, path, &test->how);
if (fd < 0 && fd == -EOPNOTSUPP) {
/*
* Skip the testcase if it failed because not supported
* by FS. (e.g. a valid O_TMPFILE combination on NFS)
*/
ksft_test_result_skip("openat2 with %s fails with %d (%s)\n",
test->name, fd, strerror(-fd));
goto next;
}

if (test->err >= 0)
failed = (fd < 0);
else
Expand Down Expand Up @@ -303,7 +313,7 @@ void test_openat2_flags(void)
else
resultfn("openat2 with %s fails with %d (%s)\n",
test->name, test->err, strerror(-test->err));

next:
free(fdpath);
fflush(stdout);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/rtc/settings
Original file line number Diff line number Diff line change
@@ -1 +1 @@
timeout=90
timeout=180
Loading

0 comments on commit 25b20ae

Please sign in to comment.