summaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/breakpoints/breakpoint_test_arm64.c94
1 files changed, 58 insertions, 36 deletions
diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
index fa6d57af5217..960d02100c26 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
@@ -43,19 +43,25 @@ static void child(int size, int wr)
volatile uint8_t *addr = &var[32 + wr];
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
- perror("ptrace(PTRACE_TRACEME) failed");
+ ksft_print_msg(
+ "ptrace(PTRACE_TRACEME) failed: %s\n",
+ strerror(errno));
_exit(1);
}
if (raise(SIGSTOP) != 0) {
- perror("raise(SIGSTOP) failed");
+ ksft_print_msg(
+ "raise(SIGSTOP) failed: %s\n", strerror(errno));
_exit(1);
}
if ((uintptr_t) addr % size) {
- perror("Wrong address write for the given size\n");
+ ksft_print_msg(
+ "Wrong address write for the given size: %s\n",
+ strerror(errno));
_exit(1);
}
+
switch (size) {
case 1:
*addr = 47;
@@ -100,11 +106,14 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
if (ptrace(PTRACE_SETREGSET, pid, NT_ARM_HW_WATCH, &iov) == 0)
return true;
- if (errno == EIO) {
- ksft_exit_skip("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) "
- "not supported on this hardware\n");
- }
- perror("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed");
+ if (errno == EIO)
+ ksft_print_msg(
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) not supported on this hardware: %s\n",
+ strerror(errno));
+
+ ksft_print_msg(
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed: %s\n",
+ strerror(errno));
return false;
}
@@ -116,7 +125,8 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
pid_t wpid;
if (pid < 0) {
- perror("fork() failed");
+ ksft_test_result_fail(
+ "fork() failed: %s\n", strerror(errno));
return false;
}
if (pid == 0)
@@ -124,15 +134,17 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg(
+ "child did not stop: %s\n", strerror(errno));
return false;
}
if (WSTOPSIG(status) != SIGSTOP) {
- printf("child did not stop with SIGSTOP\n");
+ ksft_print_msg("child did not stop with SIGSTOP\n");
return false;
}
@@ -140,42 +152,49 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
return false;
if (ptrace(PTRACE_CONT, pid, NULL, NULL) < 0) {
- perror("ptrace(PTRACE_SINGLESTEP) failed");
+ ksft_print_msg(
+ "ptrace(PTRACE_SINGLESTEP) failed: %s\n",
+ strerror(errno));
return false;
}
alarm(3);
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
alarm(0);
if (WIFEXITED(status)) {
- printf("child did not single-step\t");
+ ksft_print_msg("child did not single-step\n");
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_print_msg("child did not stop\n");
return false;
}
if (WSTOPSIG(status) != SIGTRAP) {
- printf("child did not stop with SIGTRAP\n");
+ ksft_print_msg("child did not stop with SIGTRAP\n");
return false;
}
if (ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) {
- perror("ptrace(PTRACE_GETSIGINFO)");
+ ksft_print_msg(
+ "ptrace(PTRACE_GETSIGINFO): %s\n",
+ strerror(errno));
return false;
}
if (siginfo.si_code != TRAP_HWBKPT) {
- printf("Unexpected si_code %d\n", siginfo.si_code);
+ ksft_print_msg(
+ "Unexpected si_code %d\n", siginfo.si_code);
return false;
}
kill(pid, SIGKILL);
wpid = waitpid(pid, &status, 0);
if (wpid != pid) {
- perror("waitpid() failed");
+ ksft_print_msg(
+ "waitpid() failed: %s\n", strerror(errno));
return false;
}
return true;
@@ -193,6 +212,8 @@ int main(int argc, char **argv)
int wr, wp, size;
bool result;
+ ksft_print_header();
+
act.sa_handler = sigalrm;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
@@ -200,14 +221,16 @@ int main(int argc, char **argv)
for (size = 1; size <= 32; size = size*2) {
for (wr = 0; wr <= 32; wr = wr + size) {
for (wp = wr - size; wp <= wr + size; wp = wp + size) {
- printf("Test size = %d write offset = %d watchpoint offset = %d\t", size, wr, wp);
result = run_test(size, MIN(size, 8), wr, wp);
- if ((result && wr == wp) || (!result && wr != wp)) {
- printf("[OK]\n");
- ksft_inc_pass_cnt();
- } else {
- printf("[FAILED]\n");
- ksft_inc_fail_cnt();
+ if ((result && wr == wp) ||
+ (!result && wr != wp))
+ ksft_test_result_pass(
+ "Test size = %d write offset = %d watchpoint offset = %d\n",
+ size, wr, wp);
+ else {
+ ksft_test_result_fail(
+ "Test size = %d write offset = %d watchpoint offset = %d\n",
+ size, wr, wp);
succeeded = false;
}
}
@@ -215,19 +238,18 @@ int main(int argc, char **argv)
}
for (size = 1; size <= 32; size = size*2) {
- printf("Test size = %d write offset = %d watchpoint offset = -8\t", size, -size);
-
- if (run_test(size, 8, -size, -8)) {
- printf("[OK]\n");
- ksft_inc_pass_cnt();
- } else {
- printf("[FAILED]\n");
- ksft_inc_fail_cnt();
+ if (run_test(size, 8, -size, -8))
+ ksft_test_result_pass(
+ "Test size = %d write offset = %d watchpoint offset = -8\n",
+ size, -size);
+ else {
+ ksft_test_result_fail(
+ "Test size = %d write offset = %d watchpoint offset = -8\n",
+ size, -size);
succeeded = false;
}
}
- ksft_print_cnts();
if (succeeded)
ksft_exit_pass();
else
OpenPOWER on IntegriCloud