Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: breakpoints: do not use ksft_exit_skip after ksft_set_plan

Calling ksft_exit_skip after ksft_set_plan results in executing fewer tests
than planned. Use ksft_test_result_skip for the individual tests.
The call in suspend() is fine, but ksft_set_plan should be after it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Paolo Bonzini and committed by
Shuah Khan
f000a39c ce32659b

+26 -19
+26 -19
tools/testing/selftests/breakpoints/step_after_suspend_test.c
··· 47 47 _exit(0); 48 48 } 49 49 50 - bool run_test(int cpu) 50 + int run_test(int cpu) 51 51 { 52 52 int status; 53 53 pid_t pid = fork(); ··· 55 55 56 56 if (pid < 0) { 57 57 ksft_print_msg("fork() failed: %s\n", strerror(errno)); 58 - return false; 58 + return KSFT_FAIL; 59 59 } 60 60 if (pid == 0) 61 61 child(cpu); ··· 63 63 wpid = waitpid(pid, &status, __WALL); 64 64 if (wpid != pid) { 65 65 ksft_print_msg("waitpid() failed: %s\n", strerror(errno)); 66 - return false; 66 + return KSFT_FAIL; 67 67 } 68 68 if (!WIFSTOPPED(status)) { 69 69 ksft_print_msg("child did not stop: %s\n", strerror(errno)); 70 - return false; 70 + return KSFT_FAIL; 71 71 } 72 72 if (WSTOPSIG(status) != SIGSTOP) { 73 73 ksft_print_msg("child did not stop with SIGSTOP: %s\n", 74 74 strerror(errno)); 75 - return false; 75 + return KSFT_FAIL; 76 76 } 77 77 78 78 if (ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL) < 0) { 79 79 if (errno == EIO) { 80 - ksft_exit_skip( 80 + ksft_print_msg( 81 81 "ptrace(PTRACE_SINGLESTEP) not supported on this architecture: %s\n", 82 82 strerror(errno)); 83 + return KSFT_SKIP; 83 84 } 84 85 ksft_print_msg("ptrace(PTRACE_SINGLESTEP) failed: %s\n", 85 86 strerror(errno)); 86 - return false; 87 + return KSFT_FAIL; 87 88 } 88 89 89 90 wpid = waitpid(pid, &status, __WALL); 90 91 if (wpid != pid) { 91 92 ksft_print_msg("waitpid() failed: $s\n", strerror(errno)); 92 - return false; 93 + return KSFT_FAIL; 93 94 } 94 95 if (WIFEXITED(status)) { 95 96 ksft_print_msg("child did not single-step: %s\n", 96 97 strerror(errno)); 97 - return false; 98 + return KSFT_FAIL; 98 99 } 99 100 if (!WIFSTOPPED(status)) { 100 101 ksft_print_msg("child did not stop: %s\n", strerror(errno)); 101 - return false; 102 + return KSFT_FAIL; 102 103 } 103 104 if (WSTOPSIG(status) != SIGTRAP) { 104 105 ksft_print_msg("child did not stop with SIGTRAP: %s\n", 105 106 strerror(errno)); 106 - return false; 107 + return KSFT_FAIL; 107 108 } 108 109 109 110 if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) { 110 111 ksft_print_msg("ptrace(PTRACE_CONT) failed: %s\n", 111 112 strerror(errno)); 112 - return false; 113 + return KSFT_FAIL; 113 114 } 114 115 115 116 wpid = waitpid(pid, &status, __WALL); 116 117 if (wpid != pid) { 117 118 ksft_print_msg("waitpid() failed: %s\n", strerror(errno)); 118 - return false; 119 + return KSFT_FAIL; 119 120 } 120 121 if (!WIFEXITED(status)) { 121 122 ksft_print_msg("child did not exit after PTRACE_CONT: %s\n", 122 123 strerror(errno)); 123 - return false; 124 + return KSFT_FAIL; 124 125 } 125 126 126 - return true; 127 + return KSFT_PASS; 127 128 } 128 129 129 130 void suspend(void) ··· 193 192 continue; 194 193 tests++; 195 194 } 196 - ksft_set_plan(tests); 197 195 198 196 if (do_suspend) 199 197 suspend(); 200 198 199 + ksft_set_plan(tests); 201 200 for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { 202 - bool test_success; 201 + int test_success; 203 202 204 203 if (!CPU_ISSET(cpu, &available_cpus)) 205 204 continue; 206 205 207 206 test_success = run_test(cpu); 208 - if (test_success) { 207 + switch (test_success) { 208 + case KSFT_PASS: 209 209 ksft_test_result_pass("CPU %d\n", cpu); 210 - } else { 210 + break; 211 + case KSFT_SKIP: 212 + ksft_test_result_skip("CPU %d\n", cpu); 213 + break; 214 + case KSFT_FAIL: 211 215 ksft_test_result_fail("CPU %d\n", cpu); 212 216 succeeded = false; 217 + break; 213 218 } 214 219 } 215 220