@@ -47,83 +47,84 @@ void child(int cpu)
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 ();
54
54
pid_t wpid ;
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 );
62
62
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 )
@@ -192,23 +193,29 @@ int main(int argc, char **argv)
192
193
continue ;
193
194
tests ++ ;
194
195
}
195
- ksft_set_plan (tests );
196
196
197
197
if (do_suspend )
198
198
suspend ();
199
199
200
+ ksft_set_plan (tests );
200
201
for (cpu = 0 ; cpu < CPU_SETSIZE ; cpu ++ ) {
201
- bool test_success ;
202
+ int test_success ;
202
203
203
204
if (!CPU_ISSET (cpu , & available_cpus ))
204
205
continue ;
205
206
206
207
test_success = run_test (cpu );
207
- if (test_success ) {
208
+ switch (test_success ) {
209
+ case KSFT_PASS :
208
210
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 :
210
216
ksft_test_result_fail ("CPU %d\n" , cpu );
211
217
succeeded = false;
218
+ break ;
212
219
}
213
220
}
214
221
0 commit comments