Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-5.9-rc1' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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
  ...
  • Loading branch information
Linus Torvalds committed Aug 5, 2020
2 parents 53e5504 + 850d0cc commit 4834ce9
Show file tree
Hide file tree
Showing 17 changed files with 458 additions and 247 deletions.
53 changes: 30 additions & 23 deletions tools/testing/selftests/breakpoints/step_after_suspend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,83 +47,84 @@ void child(int cpu)
_exit(0);
}

bool run_test(int cpu)
int run_test(int cpu)
{
int status;
pid_t pid = fork();
pid_t wpid;

if (pid < 0) {
ksft_print_msg("fork() failed: %s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (pid == 0)
child(cpu);

wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (!WIFSTOPPED(status)) {
ksft_print_msg("child did not stop: %s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (WSTOPSIG(status) != SIGSTOP) {
ksft_print_msg("child did not stop with SIGSTOP: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}

if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) {
if (errno == EIO) {
ksft_exit_skip(
ksft_print_msg(
"ptrace(PTRACE_SINGLESTEP) not supported on this architecture: %s\n",
strerror(errno));
return KSFT_SKIP;
}
ksft_print_msg("ptrace(PTRACE_SINGLESTEP) failed: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}

wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
ksft_print_msg("waitpid() failed: $s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (WIFEXITED(status)) {
ksft_print_msg("child did not single-step: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}
if (!WIFSTOPPED(status)) {
ksft_print_msg("child did not stop: %s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (WSTOPSIG(status) != SIGTRAP) {
ksft_print_msg("child did not stop with SIGTRAP: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}

if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) {
ksft_print_msg("ptrace(PTRACE_CONT) failed: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}

wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
ksft_print_msg("waitpid() failed: %s\n", strerror(errno));
return false;
return KSFT_FAIL;
}
if (!WIFEXITED(status)) {
ksft_print_msg("child did not exit after PTRACE_CONT: %s\n",
strerror(errno));
return false;
return KSFT_FAIL;
}

return true;
return KSFT_PASS;
}

void suspend(void)
Expand Down Expand Up @@ -183,32 +184,38 @@ int main(int argc, char **argv)
}
}

err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
if (err < 0)
ksft_exit_fail_msg("sched_getaffinity() failed\n");

for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
if (!CPU_ISSET(cpu, &available_cpus))
continue;
tests++;
}
ksft_set_plan(tests);

if (do_suspend)
suspend();

err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
if (err < 0)
ksft_exit_fail_msg("sched_getaffinity() failed\n");

ksft_set_plan(tests);
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
bool test_success;
int test_success;

if (!CPU_ISSET(cpu, &available_cpus))
continue;

test_success = run_test(cpu);
if (test_success) {
switch (test_success) {
case KSFT_PASS:
ksft_test_result_pass("CPU %d\n", cpu);
} else {
break;
case KSFT_SKIP:
ksft_test_result_skip("CPU %d\n", cpu);
break;
case KSFT_FAIL:
ksft_test_result_fail("CPU %d\n", cpu);
succeeded = false;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/clone3/clone3.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ int main(int argc, char *argv[])

uid_t uid = getuid();

test_clone3_supported();
ksft_print_header();
ksft_set_plan(17);
test_clone3_supported();

/* Just a simple clone3() should return 0.*/
test_clone3(0, 0, 0, CLONE3_ARGS_NO_TEST);
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/clone3/clone3_clear_sighand.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ static void test_clone3_clear_sighand(void)
int main(int argc, char **argv)
{
ksft_print_header();
test_clone3_supported();

ksft_set_plan(1);
test_clone3_supported();

test_clone3_clear_sighand();

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/clone3/clone3_set_tid.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ int main(int argc, char *argv[])
pid_t set_tid[MAX_PID_NS_LEVEL * 2];

ksft_print_header();
test_clone3_supported();
ksft_set_plan(29);
test_clone3_supported();

if (pipe(pipe_1) < 0 || pipe(pipe_2) < 0)
ksft_exit_fail_msg("pipe() failed\n");
Expand Down
Loading

0 comments on commit 4834ce9

Please sign in to comment.