projects/linux·commit 4b95dc87

Merge tag 'linux_kselftest-next-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

4b95dc87 · Linus Torvalds <[email protected]> · 2024-05-14 11:36:54 -07:00

Pull kselftest updates from Shuah Khan:

 - make framework and tests reporting KTAP compliant

 - make ktap_helpers and power_supply test POSIX compliant

 - add ksft_exit_fail_perror() to include errono in string form

 - avoid clang reporting false positive static analysis errors about
   functions that exit and never return. ksft_exit* functions are marked
   __noreturn to address this problem

 - add mechanism for reporting a KSFT_ result code

 - fix build warnings related missing headers and unused variables

 - fix clang build failures

 - cleanups to resctrl test

 - add host arch for LLVM builds

* tag 'linux_kselftest-next-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (44 commits)
  selftests/sgx: Include KHDR_INCLUDES in Makefile
  selftests: Compile kselftest headers with -D_GNU_SOURCE
  selftests/resctrl: fix clang build warnings related to abs(), labs() calls
  selftests/ftrace: Fix checkbashisms errors
  selftests/ftrace: Fix BTFARG testcase to check fprobe is enabled correctly
  selftests/capabilities: fix warn_unused_result build warnings
  selftests: filesystems: add missing stddef header
  selftests: kselftest_deps: fix l5_test() empty variable
  selftests: default to host arch for LLVM builds
  selftests/resctrl: fix clang build failure: use LOCAL_HDRS
  selftests/binderfs: use the Makefile's rules, not Make's implicit rules
  Documentation: kselftest: fix codeblock
  selftests: kselftest: Make ksft_exit functions return void instead of int
  selftests: x86: ksft_exit_pass() does not return
  selftests: timers: ksft_exit functions do not return
  selftests: sync: ksft_exit_pass() does not return
  selftests/resctrl: ksft_exit_skip() does not return
  selftests: pidfd: ksft_exit functions do not return
  selftests/mm: ksft_exit functions do not return
  selftests: membarrier: ksft_exit_pass() does not return
  ...
Commit
4b95dc87362aa57bdd0dcbad109ca5e5ef3cbb6c
Parents
896d3fce · 2c3b8f8f

Merge commit. Changes below are compared with the first parent: 896d3fce.

Changes

72 files changed · +703 −675

FileStatusAddDelContent
Documentation/dev-tools/kselftest.rstmodified+1−1View file
tools/testing/selftests/Makefilemodified+2−2View file
tools/testing/selftests/capabilities/test_execve.cmodified+9−3View file
tools/testing/selftests/capabilities/validate_cap.cmodified+6−1View file
tools/testing/selftests/clone3/clone3.cmodified+6−1View file
tools/testing/selftests/clone3/clone3_clear_sighand.cmodified+1−1View file
tools/testing/selftests/clone3/clone3_set_tid.cmodified+72−49View file
tools/testing/selftests/cpufreq/cpufreq.shmodified+1−2View file
tools/testing/selftests/cpufreq/main.shmodified+28−19View file
tools/testing/selftests/cpufreq/module.shmodified+2−4View file
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.cmodified+101−146View file
tools/testing/selftests/exec/recursion-depth.cmodified+5−5View file
tools/testing/selftests/filesystems/binderfs/Makefilemodified+0−2View file
tools/testing/selftests/filesystems/statmount/statmount_test.cmodified+1−0View file
tools/testing/selftests/ftrace/ftracetestmodified+7−1View file
tools/testing/selftests/ftrace/ftracetest-ktapmodified+1−1View file
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tcmodified+1−1View file
tools/testing/selftests/ftrace/test.d/dynevent/fprobe_entry_arg.tcmodified+1−1View file
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_entry_arg.tcmodified+1−1View file
tools/testing/selftests/ipc/msgque.cmodified+5−6View file
tools/testing/selftests/kselftest.hmodified+43−6View file
tools/testing/selftests/kselftest/ktap_helpers.shmodified+2−2View file
tools/testing/selftests/kselftest_deps.shmodified+1−0View file
tools/testing/selftests/kselftest_harness.hmodified+1−1View file
tools/testing/selftests/lib.mkmodified+11−3View file
tools/testing/selftests/membarrier/membarrier_test_multi_thread.cmodified+1−1View file
tools/testing/selftests/membarrier/membarrier_test_single_thread.cmodified+1−1View file
tools/testing/selftests/mm/compaction_test.cmodified+3−3View file
tools/testing/selftests/mm/cow.cmodified+1−1View file
tools/testing/selftests/mm/gup_longterm.cmodified+1−1View file
tools/testing/selftests/mm/gup_test.cmodified+2−2View file
tools/testing/selftests/mm/ksm_functional_tests.cmodified+1−1View file
tools/testing/selftests/mm/madv_populate.cmodified+1−1View file
tools/testing/selftests/mm/mkdirty.cmodified+1−1View file
tools/testing/selftests/mm/pagemap_ioctl.cmodified+2−2View file
tools/testing/selftests/mm/soft-dirty.cmodified+1−1View file
tools/testing/selftests/pidfd/pidfd_fdinfo_test.cmodified+1−1View file
tools/testing/selftests/pidfd/pidfd_open_test.cmodified+3−1View file
tools/testing/selftests/pidfd/pidfd_poll_test.cmodified+1−1View file
tools/testing/selftests/pidfd/pidfd_test.cmodified+1−1View file
tools/testing/selftests/power_supply/test_power_supply_properties.shmodified+1−1View file
tools/testing/selftests/resctrl/Makefilemodified+3−1View file
tools/testing/selftests/resctrl/cat_test.cmodified+3−5View file
tools/testing/selftests/resctrl/cmt_test.cmodified+4−4View file
tools/testing/selftests/resctrl/mba_test.cmodified+4−6View file
tools/testing/selftests/resctrl/mbm_test.cmodified+4−6View file
tools/testing/selftests/resctrl/resctrl.hmodified+3−6View file
tools/testing/selftests/resctrl/resctrl_tests.cmodified+10−16View file
tools/testing/selftests/resctrl/resctrl_val.cmodified+6−2View file
tools/testing/selftests/sgx/Makefilemodified+1−1View file
tools/testing/selftests/sgx/sigstruct.cmodified+0−1View file
tools/testing/selftests/sync/sync_test.cmodified+1−2View file
tools/testing/selftests/timers/adjtick.cmodified+2−2View file
tools/testing/selftests/timers/alarmtimer-suspend.cmodified+2−2View file
tools/testing/selftests/timers/change_skew.cmodified+2−2View file
tools/testing/selftests/timers/freq-step.cmodified+2−2View file
tools/testing/selftests/timers/leap-a-day.cmodified+5−5View file
tools/testing/selftests/timers/leapcrash.cmodified+2−2View file
tools/testing/selftests/timers/mqueue-lat.cmodified+2−2View file
tools/testing/selftests/timers/posix_timers.cmodified+6−6View file
tools/testing/selftests/timers/raw_skew.cmodified+3−3View file
tools/testing/selftests/timers/set-2038.cmodified+2−2View file
tools/testing/selftests/timers/set-tai.cmodified+2−2View file
tools/testing/selftests/timers/set-timer-lat.cmodified+2−2View file
tools/testing/selftests/timers/set-tz.cmodified+2−2View file
tools/testing/selftests/timers/skew_consistency.cmodified+2−2View file
tools/testing/selftests/timers/threadtest.cmodified+1−1View file
tools/testing/selftests/timers/valid-adjtimex.cmodified+3−3View file
tools/testing/selftests/tty/tty_tstamp_update.cmodified+33−15View file
tools/testing/selftests/x86/lam.cmodified+1−1View file
tools/testing/selftests/x86/test_mremap_vdso.cmodified+21−22View file
tools/testing/selftests/x86/test_vsyscall.cmodified+238−268View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/dev-tools/kselftest.rst

View file
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst
index ff10dc6..dcf634e 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -183,7 +183,7 @@ expected time it takes to run a test. If you have control over the systems
which will run the tests you can configure a test runner on those systems to
use a greater or lower timeout on the command line as with the `-o` or
the `--override-timeout` argument. For example to use 165 seconds instead
-one would use:
+one would use::
$ ./run_kselftest.sh --override-timeout 165

tools/testing/selftests/Makefile

View file
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index e150483..ed012a7 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),)
# $(realpath ...) resolves symlinks
abs_objtree := $(realpath $(abs_objtree))
BUILD := $(abs_objtree)/kselftest
- KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
+ KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
else
BUILD := $(CURDIR)
abs_srctree := $(shell cd $(top_srcdir) && pwd)
- KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
+ KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
DEFAULT_INSTALL_HDR_PATH := 1
endif

tools/testing/selftests/capabilities/test_execve.c

View file
diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c
index 7cde07a..47bad7d 100644
--- a/tools/testing/selftests/capabilities/test_execve.c
+++ b/tools/testing/selftests/capabilities/test_execve.c
@@ -82,7 +82,7 @@ static bool create_and_enter_ns(uid_t inner_uid)
{
uid_t outer_uid;
gid_t outer_gid;
- int i;
+ int i, ret;
bool have_outer_privilege;
outer_uid = getuid();
@@ -97,7 +97,10 @@ static bool create_and_enter_ns(uid_t inner_uid)
ksft_exit_fail_msg("setresuid - %s\n", strerror(errno));
// Re-enable effective caps
- capng_get_caps_process();
+ ret = capng_get_caps_process();
+ if (ret == -1)
+ ksft_exit_fail_msg("capng_get_caps_process failed\n");
+
for (i = 0; i < CAP_LAST_CAP; i++)
if (capng_have_capability(CAPNG_PERMITTED, i))
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, i);
@@ -207,6 +210,7 @@ static void exec_validate_cap(bool eff, bool perm, bool inh, bool ambient)
static int do_tests(int uid, const char *our_path)
{
+ int ret;
bool have_outer_privilege = create_and_enter_ns(uid);
int ourpath_fd = open(our_path, O_RDONLY | O_DIRECTORY);
@@ -250,7 +254,9 @@ static int do_tests(int uid, const char *our_path)
ksft_exit_fail_msg("chmod - %s\n", strerror(errno));
}
- capng_get_caps_process();
+ ret = capng_get_caps_process();
+ if (ret == -1)
+ ksft_exit_fail_msg("capng_get_caps_process failed\n");
/* Make sure that i starts out clear */
capng_update(CAPNG_DROP, CAPNG_INHERITABLE, CAP_NET_BIND_SERVICE);

tools/testing/selftests/capabilities/validate_cap.c

View file
diff --git a/tools/testing/selftests/capabilities/validate_cap.c b/tools/testing/selftests/capabilities/validate_cap.c
index 60b4e7b..65f2a1c 100644
--- a/tools/testing/selftests/capabilities/validate_cap.c
+++ b/tools/testing/selftests/capabilities/validate_cap.c
@@ -28,6 +28,7 @@ static bool bool_arg(char **argv, int i)
int main(int argc, char **argv)
{
const char *atsec = "";
+ int ret;
/*
* Be careful just in case a setgid or setcapped copy of this
@@ -44,7 +45,11 @@ int main(int argc, char **argv)
atsec = " (AT_SECURE is not set)";
#endif
- capng_get_caps_process();
+ ret = capng_get_caps_process();
+ if (ret == -1) {
+ ksft_print_msg("capng_get_caps_process failed\n");
+ return 1;
+ }
if (capng_have_capability(CAPNG_EFFECTIVE, CAP_NET_BIND_SERVICE) != bool_arg(argv, 1)) {
ksft_print_msg("Wrong effective state%s\n", atsec);

tools/testing/selftests/clone3/clone3.c

View file
diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
index 3c9bf0c..e61f079 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -95,9 +95,14 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
getpid(), pid);
if (waitpid(-1, &status, __WALL) < 0) {
- ksft_print_msg("Child returned %s\n", strerror(errno));
+ ksft_print_msg("waitpid() returned %s\n", strerror(errno));
return -errno;
}
+ if (!WIFEXITED(status)) {
+ ksft_print_msg("Child did not exit normally, status 0x%x\n",
+ status);
+ return EXIT_FAILURE;
+ }
if (WEXITSTATUS(status))
return WEXITSTATUS(status);

tools/testing/selftests/clone3/clone3_clear_sighand.c

View file
diff --git a/tools/testing/selftests/clone3/clone3_clear_sighand.c b/tools/testing/selftests/clone3/clone3_clear_sighand.c
index 54a8b24..ce04267 100644
--- a/tools/testing/selftests/clone3/clone3_clear_sighand.c
+++ b/tools/testing/selftests/clone3/clone3_clear_sighand.c
@@ -120,5 +120,5 @@ int main(int argc, char **argv)
test_clone3_clear_sighand();
- return ksft_exit_pass();
+ ksft_exit_pass();
}

tools/testing/selftests/clone3/clone3_set_tid.c

View file
diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c
index ed785af..bfb0da2 100644
--- a/tools/testing/selftests/clone3/clone3_set_tid.c
+++ b/tools/testing/selftests/clone3/clone3_set_tid.c
@@ -114,7 +114,8 @@ static int call_clone3_set_tid(pid_t *set_tid,
return WEXITSTATUS(status);
}
-static void test_clone3_set_tid(pid_t *set_tid,
+static void test_clone3_set_tid(const char *desc,
+ pid_t *set_tid,
size_t set_tid_size,
int flags,
int expected,
@@ -129,17 +130,13 @@ static void test_clone3_set_tid(pid_t *set_tid,
ret = call_clone3_set_tid(set_tid, set_tid_size, flags, expected_pid,
wait_for_it);
ksft_print_msg(
- "[%d] clone3() with CLONE_SET_TID %d says :%d - expected %d\n",
+ "[%d] clone3() with CLONE_SET_TID %d says: %d - expected %d\n",
getpid(), set_tid[0], ret, expected);
- if (ret != expected)
- ksft_test_result_fail(
- "[%d] Result (%d) is different than expected (%d)\n",
- getpid(), ret, expected);
- else
- ksft_test_result_pass(
- "[%d] Result (%d) matches expectation (%d)\n",
- getpid(), ret, expected);
+
+ ksft_test_result(ret == expected, "%s with %zu TIDs and flags 0x%x\n",
+ desc, set_tid_size, flags);
}
+
int main(int argc, char *argv[])
{
FILE *f;
@@ -172,73 +169,91 @@ int main(int argc, char *argv[])
/* Try invalid settings */
memset(&set_tid, 0, sizeof(set_tid));
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL + 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, 0 TID",
+ set_tid, MAX_PID_NS_LEVEL + 1, 0, -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 2, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, 0 TID",
+ set_tid, MAX_PID_NS_LEVEL * 2, 0, -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 2 + 1, 0,
- -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, 0 TID",
+ set_tid, MAX_PID_NS_LEVEL * 2 + 1, 0,
+ -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 42, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, 0 TID",
+ set_tid, MAX_PID_NS_LEVEL * 42, 0, -EINVAL, 0, 0);
/*
* This can actually work if this test running in a MAX_PID_NS_LEVEL - 1
* nested PID namespace.
*/
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL - 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, 0 TID",
+ set_tid, MAX_PID_NS_LEVEL - 1, 0, -EINVAL, 0, 0);
memset(&set_tid, 0xff, sizeof(set_tid));
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL + 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, TID all 1s",
+ set_tid, MAX_PID_NS_LEVEL + 1, 0, -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 2, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, TID all 1s",
+ set_tid, MAX_PID_NS_LEVEL * 2, 0, -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 2 + 1, 0,
- -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, TID all 1s",
+ set_tid, MAX_PID_NS_LEVEL * 2 + 1, 0,
+ -EINVAL, 0, 0);
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL * 42, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, TID all 1s",
+ set_tid, MAX_PID_NS_LEVEL * 42, 0, -EINVAL, 0, 0);
/*
* This can actually work if this test running in a MAX_PID_NS_LEVEL - 1
* nested PID namespace.
*/
- test_clone3_set_tid(set_tid, MAX_PID_NS_LEVEL - 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("invalid size, TID all 1s",
+ set_tid, MAX_PID_NS_LEVEL - 1, 0, -EINVAL, 0, 0);
memset(&set_tid, 0, sizeof(set_tid));
/* Try with an invalid PID */
set_tid[0] = 0;
- test_clone3_set_tid(set_tid, 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("valid size, 0 TID",
+ set_tid, 1, 0, -EINVAL, 0, 0);
set_tid[0] = -1;
- test_clone3_set_tid(set_tid, 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("valid size, -1 TID",
+ set_tid, 1, 0, -EINVAL, 0, 0);
/* Claim that the set_tid array actually contains 2 elements. */
- test_clone3_set_tid(set_tid, 2, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("2 TIDs, -1 and 0",
+ set_tid, 2, 0, -EINVAL, 0, 0);
/* Try it in a new PID namespace */
if (uid == 0)
- test_clone3_set_tid(set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
+ test_clone3_set_tid("valid size, -1 TID",
+ set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
else
ksft_test_result_skip("Clone3() with set_tid requires root\n");
/* Try with a valid PID (1) this should return -EEXIST. */
set_tid[0] = 1;
if (uid == 0)
- test_clone3_set_tid(set_tid, 1, 0, -EEXIST, 0, 0);
+ test_clone3_set_tid("duplicate PID 1",
+ set_tid, 1, 0, -EEXIST, 0, 0);
else
ksft_test_result_skip("Clone3() with set_tid requires root\n");
/* Try it in a new PID namespace */
if (uid == 0)
- test_clone3_set_tid(set_tid, 1, CLONE_NEWPID, 0, 0, 0);
+ test_clone3_set_tid("duplicate PID 1",
+ set_tid, 1, CLONE_NEWPID, 0, 0, 0);
else
ksft_test_result_skip("Clone3() with set_tid requires root\n");
/* pid_max should fail everywhere */
set_tid[0] = pid_max;
- test_clone3_set_tid(set_tid, 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("set TID to maximum",
+ set_tid, 1, 0, -EINVAL, 0, 0);
if (uid == 0)
- test_clone3_set_tid(set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
+ test_clone3_set_tid("set TID to maximum",
+ set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
else
ksft_test_result_skip("Clone3() with set_tid requires root\n");
@@ -262,10 +277,12 @@ int main(int argc, char *argv[])
/* After the child has finished, its PID should be free. */
set_tid[0] = pid;
- test_clone3_set_tid(set_tid, 1, 0, 0, 0, 0);
+ test_clone3_set_tid("reallocate child TID",
+ set_tid, 1, 0, 0, 0, 0);
/* This should fail as there is no PID 1 in that namespace */
- test_clone3_set_tid(set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
+ test_clone3_set_tid("duplicate child TID",
+ set_tid, 1, CLONE_NEWPID, -EINVAL, 0, 0);
/*
* Creating a process with PID 1 in the newly created most nested
@@ -274,7 +291,8 @@ int main(int argc, char *argv[])
*/
set_tid[0] = 1;
set_tid[1] = pid;
- test_clone3_set_tid(set_tid, 2, CLONE_NEWPID, 0, pid, 0);
+ test_clone3_set_tid("create PID 1 in new NS",
+ set_tid, 2, CLONE_NEWPID, 0, pid, 0);
ksft_print_msg("unshare PID namespace\n");
if (unshare(CLONE_NEWPID) == -1)
@@ -284,7 +302,8 @@ int main(int argc, char *argv[])
set_tid[0] = pid;
/* This should fail as there is no PID 1 in that namespace */
- test_clone3_set_tid(set_tid, 1, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("duplicate PID 1",
+ set_tid, 1, 0, -EINVAL, 0, 0);
/* Let's create a PID 1 */
ns_pid = fork();
@@ -295,21 +314,25 @@ int main(int argc, char *argv[])
*/
set_tid[0] = 43;
set_tid[1] = -1;
- test_clone3_set_tid(set_tid, 2, 0, -EINVAL, 0, 0);
+ test_clone3_set_tid("check leak on invalid TID -1",
+ set_tid, 2, 0, -EINVAL, 0, 0);
set_tid[0] = 43;
set_tid[1] = pid;
- test_clone3_set_tid(set_tid, 2, 0, 0, 43, 0);
+ test_clone3_set_tid("check leak on invalid specific TID",
+ set_tid, 2, 0, 0, 43, 0);
ksft_print_msg("Child in PID namespace has PID %d\n", getpid());
set_tid[0] = 2;
- test_clone3_set_tid(set_tid, 1, 0, 0, 2, 0);
+ test_clone3_set_tid("create PID 2 in child NS",
+ set_tid, 1, 0, 0, 2, 0);
set_tid[0] = 1;
set_tid[1] = -1;
set_tid[2] = pid;
/* This should fail as there is invalid PID at level '1'. */
- test_clone3_set_tid(set_tid, 3, CLONE_NEWPID, -EINVAL, 0, 0);
+ test_clone3_set_tid("fail due to invalid TID at level 1",
+ set_tid, 3, CLONE_NEWPID, -EINVAL, 0, 0);
set_tid[0] = 1;
set_tid[1] = 42;
@@ -319,13 +342,15 @@ int main(int argc, char *argv[])
* namespaces. Again assuming this is running in the host's
* PID namespace. Not yet nested.
*/
- test_clone3_set_tid(set_tid, 4, CLONE_NEWPID, -EINVAL, 0, 0);
+ test_clone3_set_tid("fail due to too few active PID NSs",
+ set_tid, 4, CLONE_NEWPID, -EINVAL, 0, 0);
/*
* This should work and from the parent we should see
* something like 'NSpid: pid 42 1'.
*/
- test_clone3_set_tid(set_tid, 3, CLONE_NEWPID, 0, 42, true);
+ test_clone3_set_tid("verify that we have 3 PID NSs",
+ set_tid, 3, CLONE_NEWPID, 0, 42, true);
child_exit(ksft_cnt.ksft_fail);
}
@@ -380,16 +405,14 @@ int main(int argc, char *argv[])
ksft_cnt.ksft_pass += 6 - (ksft_cnt.ksft_fail - WEXITSTATUS(status));
ksft_cnt.ksft_fail = WEXITSTATUS(status);
- if (ns3 == pid && ns2 == 42 && ns1 == 1)
- ksft_test_result_pass(
- "PIDs in all namespaces as expected (%d,%d,%d)\n",
- ns3, ns2, ns1);
- else
- ksft_test_result_fail(
- "PIDs in all namespaces not as expected (%d,%d,%d)\n",
- ns3, ns2, ns1);
+ ksft_print_msg("Expecting PIDs %d, 42, 1\n", pid);
+ ksft_print_msg("Have PIDs in namespaces: %d, %d, %d\n", ns3, ns2, ns1);
+ ksft_test_result(ns3 == pid && ns2 == 42 && ns1 == 1,
+ "PIDs in all namespaces as expected\n");
out:
ret = 0;
- return !ret ? ksft_exit_pass() : ksft_exit_fail();
+ if (ret)
+ ksft_exit_fail();
+ ksft_exit_pass();
}

tools/testing/selftests/cpufreq/cpufreq.sh

View file
diff --git a/tools/testing/selftests/cpufreq/cpufreq.sh b/tools/testing/selftests/cpufreq/cpufreq.sh
index b583a2f..a8b1dbc 100755
--- a/tools/testing/selftests/cpufreq/cpufreq.sh
+++ b/tools/testing/selftests/cpufreq/cpufreq.sh
@@ -178,8 +178,7 @@ cpufreq_basic_tests()
count=$(count_cpufreq_managed_cpus)
if [ $count = 0 ]; then
- printf "No cpu is managed by cpufreq core, exiting\n"
- exit;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting\n"
else
printf "CPUFreq manages: $count CPUs\n\n"
fi

tools/testing/selftests/cpufreq/main.sh

View file
diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/selftests/cpufreq/main.sh
index 60ce18e..a0eb84c 100755
--- a/tools/testing/selftests/cpufreq/main.sh
+++ b/tools/testing/selftests/cpufreq/main.sh
@@ -7,15 +7,15 @@ source governor.sh
source module.sh
source special-tests.sh
+DIR="$(dirname $(readlink -f "$0"))"
+source "${DIR}"/../kselftest/ktap_helpers.sh
+
FUNC=basic # do basic tests by default
OUTFILE=cpufreq_selftest
SYSFS=
CPUROOT=
CPUFREQROOT=
-# Kselftest framework requirement - SKIP code is 4.
-ksft_skip=4
-
helpme()
{
printf "Usage: $0 [-h] [-todg args]
@@ -32,7 +32,7 @@ helpme()
[-d <driver's module name: only with \"-t modtest>\"]
[-g <governor's module name: only with \"-t modtest>\"]
\n"
- exit 2
+ exit "${KSFT_FAIL}"
}
prerequisite()
@@ -40,8 +40,8 @@ prerequisite()
msg="skip all tests:"
if [ $UID != 0 ]; then
- echo $msg must be run as root >&2
- exit $ksft_skip
+ ktap_skip_all "$msg must be run as root"
+ exit "${KSFT_SKIP}"
fi
taskset -p 01 $$
@@ -49,21 +49,21 @@ prerequisite()
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then
- echo $msg sysfs is not mounted >&2
- exit 2
+ ktap_skip_all "$msg sysfs is not mounted"
+ exit "${KSFT_SKIP}"
fi
CPUROOT=$SYSFS/devices/system/cpu
CPUFREQROOT="$CPUROOT/cpufreq"
if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
- echo $msg cpus not available in sysfs >&2
- exit 2
+ ktap_skip_all "$msg cpus not available in sysfs"
+ exit "${KSFT_SKIP}"
fi
if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
- echo $msg cpufreq directory not available in sysfs >&2
- exit 2
+ ktap_skip_all "$msg cpufreq directory not available in sysfs"
+ exit "${KSFT_SKIP}"
fi
}
@@ -105,8 +105,7 @@ do_test()
count=$(count_cpufreq_managed_cpus)
if [ $count = 0 -a $FUNC != "modtest" ]; then
- echo "No cpu is managed by cpufreq core, exiting"
- exit 2;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
fi
case "$FUNC" in
@@ -125,8 +124,7 @@ do_test()
"modtest")
# Do we have modules in place?
if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
- echo "No driver or governor module passed with -d or -g"
- exit 2;
+ ktap_exit_fail_msg "No driver or governor module passed with -d or -g"
fi
if [ $DRIVER_MOD ]; then
@@ -137,8 +135,7 @@ do_test()
fi
else
if [ $count = 0 ]; then
- echo "No cpu is managed by cpufreq core, exiting"
- exit 2;
+ ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
fi
module_governor_test $GOVERNOR_MOD
@@ -162,7 +159,7 @@ do_test()
;;
*)
- echo "Invalid [-f] function type"
+ ktap_print_msg "Invalid [-f] function type"
helpme
;;
esac
@@ -186,13 +183,25 @@ dmesg_dumps()
dmesg >> $1.dmesg_full.txt
}
+ktap_print_header
+
# Parse arguments
parse_arguments $@
+ktap_set_plan 1
+
# Make sure all requirements are met
prerequisite
# Run requested functions
clear_dumps $OUTFILE
do_test | tee -a $OUTFILE.txt
+if [ "${PIPESTATUS[0]}" -ne 0 ]; then
+ exit ${PIPESTATUS[0]};
+fi
dmesg_dumps $OUTFILE
+
+ktap_test_pass "Completed successfully"
+
+ktap_print_totals
+exit "${KSFT_PASS}"

tools/testing/selftests/cpufreq/module.sh

View file
diff --git a/tools/testing/selftests/cpufreq/module.sh b/tools/testing/selftests/cpufreq/module.sh
index 22563cd..7f2667e 100755
--- a/tools/testing/selftests/cpufreq/module.sh
+++ b/tools/testing/selftests/cpufreq/module.sh
@@ -24,16 +24,14 @@ test_basic_insmod_rmmod()
# insert module
insmod $1
if [ $? != 0 ]; then
- printf "Insmod $1 failed\n"
- exit;
+ ktap_exit_fail_msg "Insmod $1 failed\n"
fi
printf "Removing $1 module\n"
# remove module
rmmod $1
if [ $? != 0 ]; then
- printf "rmmod $1 failed\n"
- exit;
+ ktap_exit_fail_msg "rmmod $1 failed\n"
fi
printf "\n"

tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

View file
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index 890a823..5f54152 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -15,6 +15,7 @@
#include <linux/dma-buf.h>
#include <linux/dma-heap.h>
#include <drm/drm.h>
+#include "../kselftest.h"
#define DEVPATH "/dev/dma_heap"
@@ -90,14 +91,13 @@ static int dmabuf_heap_open(char *name)
char buf[256];
ret = snprintf(buf, 256, "%s/%s", DEVPATH, name);
- if (ret < 0) {
- printf("snprintf failed!\n");
- return ret;
- }
+ if (ret < 0)
+ ksft_exit_fail_msg("snprintf failed! %d\n", ret);
fd = open(buf, O_RDWR);
if (fd < 0)
- printf("open %s failed!\n", buf);
+ ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno));
+
return fd;
}
@@ -140,7 +140,7 @@ static int dmabuf_sync(int fd, int start_stop)
#define ONE_MEG (1024 * 1024)
-static int test_alloc_and_import(char *heap_name)
+static void test_alloc_and_import(char *heap_name)
{
int heap_fd = -1, dmabuf_fd = -1, importer_fd = -1;
uint32_t handle = 0;

This diff is incomplete. Download the complete patch.

tools/testing/selftests/exec/recursion-depth.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/filesystems/binderfs/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/filesystems/statmount/statmount_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ftrace/ftracetest

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ftrace/ftracetest-ktap

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ftrace/test.d/dynevent/fprobe_entry_arg.tc

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_entry_arg.tc

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/ipc/msgque.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kselftest.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kselftest/ktap_helpers.sh

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kselftest_deps.sh

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kselftest_harness.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/lib.mk

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/membarrier/membarrier_test_multi_thread.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/membarrier/membarrier_test_single_thread.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/compaction_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/cow.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/gup_longterm.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/gup_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/ksm_functional_tests.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/madv_populate.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/mkdirty.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/pagemap_ioctl.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mm/soft-dirty.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/pidfd/pidfd_fdinfo_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/pidfd/pidfd_open_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/pidfd/pidfd_poll_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/pidfd/pidfd_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/power_supply/test_power_supply_properties.sh

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/cat_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/cmt_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/mba_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/mbm_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/resctrl.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/resctrl_tests.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/resctrl/resctrl_val.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/sgx/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/sgx/sigstruct.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/sync/sync_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/adjtick.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/alarmtimer-suspend.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/change_skew.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/freq-step.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/leap-a-day.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/leapcrash.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/mqueue-lat.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/posix_timers.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/raw_skew.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/set-2038.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/set-tai.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/set-timer-lat.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/set-tz.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/skew_consistency.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/threadtest.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/timers/valid-adjtimex.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/tty/tty_tstamp_update.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/x86/lam.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/x86/test_mremap_vdso.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/x86/test_vsyscall.c

View file

This diff is incomplete. Download the complete patch.