Skip to content

Commit b901216

Browse files
Rahi374Shuah Khan
authored andcommitted
kselftest: breakpoints: convert step_after_suspend_test to TAP13 output
Make the step_after_suspend test output in the TAP13 format by using the TAP13 output functions defined in kselftest.h Signed-off-by: Paul Elder <paul.elder@pitt.edu> Signed-off-by: Alice Ferrazzi <alice.ferrazzi@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
1 parent 748e84b commit b901216

1 file changed

Lines changed: 17 additions & 26 deletions

File tree

‎tools/testing/selftests/breakpoints/step_after_suspend_test.c‎

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,21 @@ void suspend(void)
135135
struct itimerspec spec = {};
136136

137137
power_state_fd = open("/sys/power/state", O_RDWR);
138-
if (power_state_fd < 0) {
139-
perror("open(\"/sys/power/state\") failed (is this test running as root?)");
140-
ksft_exit_fail();
141-
}
138+
if (power_state_fd < 0)
139+
ksft_exit_fail_msg(
140+
"open(\"/sys/power/state\") failed (is this test running as root?)");
142141

143142
timerfd = timerfd_create(CLOCK_BOOTTIME_ALARM, 0);
144-
if (timerfd < 0) {
145-
perror("timerfd_create() failed");
146-
ksft_exit_fail();
147-
}
143+
if (timerfd < 0)
144+
ksft_exit_fail_msg("timerfd_create() failed");
148145

149146
spec.it_value.tv_sec = 5;
150147
err = timerfd_settime(timerfd, 0, &spec, NULL);
151-
if (err < 0) {
152-
perror("timerfd_settime() failed");
153-
ksft_exit_fail();
154-
}
148+
if (err < 0)
149+
ksft_exit_fail_msg("timerfd_settime() failed");
155150

156-
if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem")) {
157-
perror("entering suspend failed");
158-
ksft_exit_fail();
159-
}
151+
if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
152+
ksft_exit_fail_msg("entering suspend failed");
160153

161154
close(timerfd);
162155
close(power_state_fd);
@@ -170,6 +163,9 @@ int main(int argc, char **argv)
170163
cpu_set_t available_cpus;
171164
int err;
172165
int cpu;
166+
char buf[10];
167+
168+
ksft_print_header();
173169

174170
while ((opt = getopt(argc, argv, "n")) != -1) {
175171
switch (opt) {
@@ -187,10 +183,8 @@ int main(int argc, char **argv)
187183
suspend();
188184

189185
err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
190-
if (err < 0) {
191-
perror("sched_getaffinity() failed");
192-
ksft_exit_fail();
193-
}
186+
if (err < 0)
187+
ksft_exit_fail_msg("sched_getaffinity() failed");
194188

195189
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
196190
bool test_success;
@@ -199,18 +193,15 @@ int main(int argc, char **argv)
199193
continue;
200194

201195
test_success = run_test(cpu);
202-
printf("CPU %d: ", cpu);
196+
sprintf(buf, "CPU %d", cpu);
203197
if (test_success) {
204-
printf("[OK]\n");
205-
ksft_inc_pass_cnt();
198+
ksft_test_result_pass(buf);
206199
} else {
207-
printf("[FAILED]\n");
208-
ksft_inc_fail_cnt();
200+
ksft_test_result_fail(buf);
209201
succeeded = false;
210202
}
211203
}
212204

213-
ksft_print_cnts();
214205
if (succeeded)
215206
ksft_exit_pass();
216207
else

0 commit comments

Comments
 (0)