Skip to content

Commit 4834ce9

Browse files
committed
Merge tag 'linux-kselftest-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates form Shuah Khan: - TAP output reporting related fixes from Paolo Bonzini and Kees Cook. These fixes make it skip reporting consistent with TAP format. - Cleanup fixes to framework run_tests from Yauheni Kaliuta * tag 'linux-kselftest-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (23 commits) selftests/harness: Limit step counter reporting selftests/seccomp: Check ENOSYS under tracing selftests/seccomp: Refactor to use fixture variants selftests/harness: Clean up kern-doc for fixtures selftests: kmod: Add module address visibility test Replace HTTP links with HTTPS ones: KMOD KERNEL MODULE LOADER - USERMODE HELPER selftests: fix condition in run_tests selftests: do not use .ONESHELL selftests: pidfd: skip test if unshare fails with EPERM selftests: pidfd: do not use ksft_exit_skip after ksft_set_plan selftests/harness: Report skip reason selftests/harness: Display signed values correctly selftests/harness: Refactor XFAIL into SKIP selftests/harness: Switch to TAP output selftests: Add header documentation and helpers selftests/binderfs: Fix harness API usage selftests: Remove unneeded selftest API headers selftests/clone3: Reorder reporting output selftests: sync_test: do not use ksft_exit_skip after ksft_set_plan selftests: sigaltstack: do not use ksft_exit_skip after ksft_set_plan ...
2 parents 53e5504 + 850d0cc commit 4834ce9

File tree

17 files changed

+458
-247
lines changed

17 files changed

+458
-247
lines changed

tools/testing/selftests/breakpoints/step_after_suspend_test.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,83 +47,84 @@ void child(int cpu)
4747
_exit(0);
4848
}
4949

50-
bool run_test(int cpu)
50+
int run_test(int cpu)
5151
{
5252
int status;
5353
pid_t pid = fork();
5454
pid_t wpid;
5555

5656
if (pid < 0) {
5757
ksft_print_msg("fork() failed: %s\n", strerror(errno));
58-
return false;
58+
return KSFT_FAIL;
5959
}
6060
if (pid == 0)
6161
child(cpu);
6262

6363
wpid = waitpid(pid, &status, __WALL);
6464
if (wpid != pid) {
6565
ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
66-
return false;
66+
return KSFT_FAIL;
6767
}
6868
if (!WIFSTOPPED(status)) {
6969
ksft_print_msg("child did not stop: %s\n", strerror(errno));
70-
return false;
70+
return KSFT_FAIL;
7171
}
7272
if (WSTOPSIG(status) != SIGSTOP) {
7373
ksft_print_msg("child did not stop with SIGSTOP: %s\n",
7474
strerror(errno));
75-
return false;
75+
return KSFT_FAIL;
7676
}
7777

7878
if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) {
7979
if (errno == EIO) {
80-
ksft_exit_skip(
80+
ksft_print_msg(
8181
"ptrace(PTRACE_SINGLESTEP) not supported on this architecture: %s\n",
8282
strerror(errno));
83+
return KSFT_SKIP;
8384
}
8485
ksft_print_msg("ptrace(PTRACE_SINGLESTEP) failed: %s\n",
8586
strerror(errno));
86-
return false;
87+
return KSFT_FAIL;
8788
}
8889

8990
wpid = waitpid(pid, &status, __WALL);
9091
if (wpid != pid) {
9192
ksft_print_msg("waitpid() failed: $s\n", strerror(errno));
92-
return false;
93+
return KSFT_FAIL;
9394
}
9495
if (WIFEXITED(status)) {
9596
ksft_print_msg("child did not single-step: %s\n",
9697
strerror(errno));
97-
return false;
98+
return KSFT_FAIL;
9899
}
99100
if (!WIFSTOPPED(status)) {
100101
ksft_print_msg("child did not stop: %s\n", strerror(errno));
101-
return false;
102+
return KSFT_FAIL;
102103
}
103104
if (WSTOPSIG(status) != SIGTRAP) {
104105
ksft_print_msg("child did not stop with SIGTRAP: %s\n",
105106
strerror(errno));
106-
return false;
107+
return KSFT_FAIL;
107108
}
108109

109110
if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) {
110111
ksft_print_msg("ptrace(PTRACE_CONT) failed: %s\n",
111112
strerror(errno));
112-
return false;
113+
return KSFT_FAIL;
113114
}
114115

115116
wpid = waitpid(pid, &status, __WALL);
116117
if (wpid != pid) {
117118
ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
118-
return false;
119+
return KSFT_FAIL;
119120
}
120121
if (!WIFEXITED(status)) {
121122
ksft_print_msg("child did not exit after PTRACE_CONT: %s\n",
122123
strerror(errno));
123-
return false;
124+
return KSFT_FAIL;
124125
}
125126

126-
return true;
127+
return KSFT_PASS;
127128
}
128129

129130
void suspend(void)
@@ -183,32 +184,38 @@ int main(int argc, char **argv)
183184
}
184185
}
185186

187+
err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
188+
if (err < 0)
189+
ksft_exit_fail_msg("sched_getaffinity() failed\n");
190+
186191
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
187192
if (!CPU_ISSET(cpu, &available_cpus))
188193
continue;
189194
tests++;
190195
}
191-
ksft_set_plan(tests);
192196

193197
if (do_suspend)
194198
suspend();
195199

196-
err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
197-
if (err < 0)
198-
ksft_exit_fail_msg("sched_getaffinity() failed\n");
199-
200+
ksft_set_plan(tests);
200201
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
201-
bool test_success;
202+
int test_success;
202203

203204
if (!CPU_ISSET(cpu, &available_cpus))
204205
continue;
205206

206207
test_success = run_test(cpu);
207-
if (test_success) {
208+
switch (test_success) {
209+
case KSFT_PASS:
208210
ksft_test_result_pass("CPU %d\n", cpu);
209-
} else {
211+
break;
212+
case KSFT_SKIP:
213+
ksft_test_result_skip("CPU %d\n", cpu);
214+
break;
215+
case KSFT_FAIL:
210216
ksft_test_result_fail("CPU %d\n", cpu);
211217
succeeded = false;
218+
break;
212219
}
213220
}
214221

tools/testing/selftests/clone3/clone3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ int main(int argc, char *argv[])
131131

132132
uid_t uid = getuid();
133133

134-
test_clone3_supported();
135134
ksft_print_header();
136135
ksft_set_plan(17);
136+
test_clone3_supported();
137137

138138
/* Just a simple clone3() should return 0.*/
139139
test_clone3(0, 0, 0, CLONE3_ARGS_NO_TEST);

tools/testing/selftests/clone3/clone3_clear_sighand.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ static void test_clone3_clear_sighand(void)
119119
int main(int argc, char **argv)
120120
{
121121
ksft_print_header();
122-
test_clone3_supported();
123-
124122
ksft_set_plan(1);
123+
test_clone3_supported();
125124

126125
test_clone3_clear_sighand();
127126

tools/testing/selftests/clone3/clone3_set_tid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ int main(int argc, char *argv[])
157157
pid_t set_tid[MAX_PID_NS_LEVEL * 2];
158158

159159
ksft_print_header();
160-
test_clone3_supported();
161160
ksft_set_plan(29);
161+
test_clone3_supported();
162162

163163
if (pipe(pipe_1) < 0 || pipe(pipe_2) < 0)
164164
ksft_exit_fail_msg("pipe() failed\n");

0 commit comments

Comments
 (0)