Skip to content

Commit 748e84b

Browse files
Rahi374Shuah Khan
authored andcommitted
kselftest: breakpoints: convert breakpoint_test to TAP13 output
Make the breakpoints 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 326f57a commit 748e84b

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ static void set_breakpoint_addr(void *addr, int n)
4242

4343
ret = ptrace(PTRACE_POKEUSER, child_pid,
4444
offsetof(struct user, u_debugreg[n]), addr);
45-
if (ret) {
46-
perror("Can't set breakpoint addr\n");
47-
ksft_exit_fail();
48-
}
45+
if (ret)
46+
ksft_exit_fail_msg("Can't set breakpoint addr");
4947
}
5048

5149
static void toggle_breakpoint(int n, int type, int len,
@@ -105,10 +103,8 @@ static void toggle_breakpoint(int n, int type, int len,
105103

106104
ret = ptrace(PTRACE_POKEUSER, child_pid,
107105
offsetof(struct user, u_debugreg[7]), dr7);
108-
if (ret) {
109-
perror("Can't set dr7");
110-
ksft_exit_fail();
111-
}
106+
if (ret)
107+
ksft_exit_fail_msg("Can't set dr7");
112108
}
113109

114110
/* Dummy variables to test read/write accesses */
@@ -264,26 +260,29 @@ static void check_success(const char *msg)
264260
const char *msg2;
265261
int child_nr_tests;
266262
int status;
263+
int ret;
267264

268265
/* Wait for the child to SIGTRAP */
269266
wait(&status);
270267

271268
msg2 = "Failed";
269+
ret = 0;
272270

273271
if (WSTOPSIG(status) == SIGTRAP) {
274272
child_nr_tests = ptrace(PTRACE_PEEKDATA, child_pid,
275273
&nr_tests, 0);
276274
if (child_nr_tests == nr_tests)
277-
msg2 = "Ok";
278-
if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) {
279-
perror("Can't poke\n");
280-
ksft_exit_fail();
281-
}
275+
ret = 1;
276+
if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1))
277+
ksft_exit_fail_msg("Can't poke");
282278
}
283279

284280
nr_tests++;
285281

286-
printf("%s [%s]\n", msg, msg2);
282+
if (ret)
283+
ksft_test_result_pass(msg);
284+
else
285+
ksft_test_result_fail(msg);
287286
}
288287

289288
static void launch_instruction_breakpoints(char *buf, int local, int global)
@@ -378,6 +377,8 @@ int main(int argc, char **argv)
378377
pid_t pid;
379378
int ret;
380379

380+
ksft_print_header();
381+
381382
pid = fork();
382383
if (!pid) {
383384
trigger_tests();

0 commit comments

Comments
 (0)