2017-06-27 16:04:58

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

Convert breakpoint_test_arm64 output to TAP13 format.

Signed-off-by: Shuah Khan <[email protected]>
---
.../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
1 file changed, 79 insertions(+), 35 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
index fa6d57af5217..d13bd0dea13e 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
@@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
static void child(int size, int wr)
{
volatile uint8_t *addr = &var[32 + wr];
+ char msg_buf[512];

if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
- perror("ptrace(PTRACE_TRACEME) failed");
- _exit(1);
+ snprintf(msg_buf, sizeof(msg_buf),
+ "ptrace(PTRACE_TRACEME) failed: %s\n",
+ strerror(errno));
+ ksft_exit_fail_msg(msg_buf);
}

if (raise(SIGSTOP) != 0) {
- perror("raise(SIGSTOP) failed");
- _exit(1);
+ snprintf(msg_buf, sizeof(msg_buf),
+ "raise(SIGSTOP) failed: %s\n",
+ strerror(errno));
+ ksft_exit_fail_msg(msg_buf);
}

if ((uintptr_t) addr % size) {
- perror("Wrong address write for the given size\n");
- _exit(1);
+ snprintf(msg_buf, sizeof(msg_buf),
+ "Wrong address write for the given size: %s\n",
+ strerror(errno));
+ ksft_exit_fail_msg(msg_buf);
}
switch (size) {
case 1:
@@ -90,6 +97,7 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
const unsigned int control = byte_mask << 5 | type << 3 | enable;
struct user_hwdebug_state dreg_state;
struct iovec iov;
+ char msg_buf[512];

memset(&dreg_state, 0, sizeof(dreg_state));
dreg_state.dbg_regs[0].addr = (uintptr_t)(addr - offset);
@@ -101,10 +109,15 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
return true;

if (errno == EIO) {
- ksft_exit_skip("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) "
- "not supported on this hardware\n");
+ snprintf(msg_buf, sizeof(msg_buf),
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) not supported on this hardware: %s\n",
+ strerror(errno));
+ ksft_exit_skip(msg_buf);
}
- perror("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed");
+ snprintf(msg_buf, sizeof(msg_buf),
+ "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(msg_buf);
return false;
}

@@ -114,9 +127,14 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
siginfo_t siginfo;
pid_t pid = fork();
pid_t wpid;
+ char buf[512];
+ char buf2[512];

if (pid < 0) {
- perror("fork() failed");
+ snprintf(buf, sizeof(buf),
+ "fork() failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf);
return false;
}
if (pid == 0)
@@ -124,15 +142,22 @@ 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");
+ snprintf(buf, sizeof(buf),
+ "waitpid() failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf);
return false;
}
if (!WIFSTOPPED(status)) {
printf("child did not stop\n");
+ snprintf(buf, sizeof(buf),
+ "child did not stop: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf);
return false;
}
if (WSTOPSIG(status) != SIGSTOP) {
- printf("child did not stop with SIGSTOP\n");
+ ksft_test_result_fail("child did not stop with SIGSTOP\n");
return false;
}

@@ -140,42 +165,58 @@ 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");
+ snprintf(buf, sizeof(buf),
+ "ptrace(PTRACE_SINGLESTEP) failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf);
return false;
}

alarm(3);
wpid = waitpid(pid, &status, __WALL);
if (wpid != pid) {
- perror("waitpid() failed");
+ snprintf(buf2, sizeof(buf2),
+ "waitpid() failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf2);
return false;
}
alarm(0);
if (WIFEXITED(status)) {
- printf("child did not single-step\t");
+ ksft_test_result_fail("child did not single-step\t");
return false;
}
if (!WIFSTOPPED(status)) {
- printf("child did not stop\n");
+ ksft_test_result_fail("child did not stop\n");
return false;
}
if (WSTOPSIG(status) != SIGTRAP) {
- printf("child did not stop with SIGTRAP\n");
+ ksft_test_result_fail("child did not stop with SIGTRAP\n");
return false;
}
if (ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) {
perror("ptrace(PTRACE_GETSIGINFO)");
+ snprintf(buf2, sizeof(buf2),
+ "ptrace(PTRACE_GETSIGINFO): %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf2);
return false;
}
if (siginfo.si_code != TRAP_HWBKPT) {
- printf("Unexpected si_code %d\n", siginfo.si_code);
+ snprintf(buf2, sizeof(buf2),
+ "Unexpected si_code %d\n",
+ siginfo.si_code);
+ ksft_test_result_fail(buf2);
return false;
}

kill(pid, SIGKILL);
wpid = waitpid(pid, &status, 0);
if (wpid != pid) {
- perror("waitpid() failed");
+ snprintf(buf2, sizeof(buf2),
+ "waitpid() failed: %s\n",
+ strerror(errno));
+ ksft_test_result_fail(buf2);
return false;
}
return true;
@@ -192,6 +233,9 @@ int main(int argc, char **argv)
struct sigaction act;
int wr, wp, size;
bool result;
+ char msg_buf[512];
+
+ ksft_print_header();

act.sa_handler = sigalrm;
sigemptyset(&act.sa_mask);
@@ -200,14 +244,15 @@ 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);
+ snprintf(msg_buf, sizeof(msg_buf),
+ "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(msg_buf);
+ else {
+ ksft_test_result_fail(msg_buf);
succeeded = false;
}
}
@@ -215,19 +260,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();
+ snprintf(msg_buf, sizeof(msg_buf),
+ "Test size = %d write offset = %d watchpoint offset = -8\t",
+ size, -size);
+
+ if (run_test(size, 8, -size, -8))
+ ksft_test_result_pass(msg_buf);
+ else {
+ ksft_test_result_fail(msg_buf);
succeeded = false;
}
}

- ksft_print_cnts();
if (succeeded)
ksft_exit_pass();
else
--
2.11.0


2017-06-27 16:12:08

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

On Tue, Jun 27, 2017 at 10:04:47AM -0600, Shuah Khan wrote:
> Convert breakpoint_test_arm64 output to TAP13 format.
>
> Signed-off-by: Shuah Khan <[email protected]>
> ---
> .../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
> 1 file changed, 79 insertions(+), 35 deletions(-)
>
> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> index fa6d57af5217..d13bd0dea13e 100644
> --- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> +++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> @@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
> static void child(int size, int wr)
> {
> volatile uint8_t *addr = &var[32 + wr];
> + char msg_buf[512];
>
> if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
> - perror("ptrace(PTRACE_TRACEME) failed");
> - _exit(1);
> + snprintf(msg_buf, sizeof(msg_buf),
> + "ptrace(PTRACE_TRACEME) failed: %s\n",
> + strerror(errno));
> + ksft_exit_fail_msg(msg_buf);

No objection to this patch, but perhaps the "msg" functions could either
be variable arg macros, or just a printk() like function that can take
the string and anything you want to send to it.

So this could be:
ksft_exit_fail_msg("ptrace(PTRACE_TRACEME) failed: %s\n", strerror(errno));

Anyway, just a thought, might make conversions a lot easier, no need for
intermediate buffers.

thanks,

greg k-h

2017-06-27 16:37:07

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

On 06/27/2017 10:11 AM, Greg KH wrote:
> On Tue, Jun 27, 2017 at 10:04:47AM -0600, Shuah Khan wrote:
>> Convert breakpoint_test_arm64 output to TAP13 format.
>>
>> Signed-off-by: Shuah Khan <[email protected]>
>> ---
>> .../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
>> 1 file changed, 79 insertions(+), 35 deletions(-)
>>
>> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>> index fa6d57af5217..d13bd0dea13e 100644
>> --- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>> +++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>> @@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
>> static void child(int size, int wr)
>> {
>> volatile uint8_t *addr = &var[32 + wr];
>> + char msg_buf[512];
>>
>> if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
>> - perror("ptrace(PTRACE_TRACEME) failed");
>> - _exit(1);
>> + snprintf(msg_buf, sizeof(msg_buf),
>> + "ptrace(PTRACE_TRACEME) failed: %s\n",
>> + strerror(errno));
>> + ksft_exit_fail_msg(msg_buf);
>
> No objection to this patch, but perhaps the "msg" functions could either
> be variable arg macros, or just a printk() like function that can take
> the string and anything you want to send to it.

Right. Changing "msg" functions to take var args will make things easier.
I will take care of that and use this test for a use-case.

>
> So this could be:
> ksft_exit_fail_msg("ptrace(PTRACE_TRACEME) failed: %s\n", strerror(errno));

Right.

>
> Anyway, just a thought, might make conversions a lot easier, no need for
> intermediate buffers>
> thanks,
>
> greg k-h
>

thanks,
-- Shuah

2017-06-27 16:47:31

by Paul Elder

[permalink] [raw]
Subject: Re: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

On 06/28/2017 01:04 AM, Shuah Khan wrote:
> Convert breakpoint_test_arm64 output to TAP13 format.
>
> Signed-off-by: Shuah Khan <[email protected]>
> ---
> .../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
> 1 file changed, 79 insertions(+), 35 deletions(-)
>
> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> index fa6d57af5217..d13bd0dea13e 100644
> --- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> +++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
> @@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
> static void child(int size, int wr)
> {
> volatile uint8_t *addr = &var[32 + wr];
> + char msg_buf[512];
>
> if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
> - perror("ptrace(PTRACE_TRACEME) failed");
> - _exit(1);
> + snprintf(msg_buf, sizeof(msg_buf),
> + "ptrace(PTRACE_TRACEME) failed: %s\n",
> + strerror(errno));
> + ksft_exit_fail_msg(msg_buf);
> }
>
> if (raise(SIGSTOP) != 0) {
> - perror("raise(SIGSTOP) failed");
> - _exit(1);
> + snprintf(msg_buf, sizeof(msg_buf),
> + "raise(SIGSTOP) failed: %s\n",
> + strerror(errno));
> + ksft_exit_fail_msg(msg_buf);
> }
>
> if ((uintptr_t) addr % size) {
> - perror("Wrong address write for the given size\n");
> - _exit(1);
> + snprintf(msg_buf, sizeof(msg_buf),
> + "Wrong address write for the given size: %s\n",
> + strerror(errno));
> + ksft_exit_fail_msg(msg_buf);
> }
> switch (size) {
> case 1:
> @@ -90,6 +97,7 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
> const unsigned int control = byte_mask << 5 | type << 3 | enable;
> struct user_hwdebug_state dreg_state;
> struct iovec iov;
> + char msg_buf[512];
>
> memset(&dreg_state, 0, sizeof(dreg_state));
> dreg_state.dbg_regs[0].addr = (uintptr_t)(addr - offset);
> @@ -101,10 +109,15 @@ static bool set_watchpoint(pid_t pid, int size, int wp)
> return true;
>
> if (errno == EIO) {
> - ksft_exit_skip("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) "
> - "not supported on this hardware\n");
> + snprintf(msg_buf, sizeof(msg_buf),
> + "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) not supported on this hardware: %s\n",
> + strerror(errno));
> + ksft_exit_skip(msg_buf);
> }
> - perror("ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed");
> + snprintf(msg_buf, sizeof(msg_buf),
> + "ptrace(PTRACE_SETREGSET, NT_ARM_HW_WATCH) failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(msg_buf);
> return false;
> }
>
> @@ -114,9 +127,14 @@ static bool run_test(int wr_size, int wp_size, int wr, int wp)
> siginfo_t siginfo;
> pid_t pid = fork();
> pid_t wpid;
> + char buf[512];
> + char buf2[512];
>
> if (pid < 0) {
> - perror("fork() failed");
> + snprintf(buf, sizeof(buf),
> + "fork() failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf);
> return false;
> }
> if (pid == 0)
> @@ -124,15 +142,22 @@ 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");
> + snprintf(buf, sizeof(buf),
> + "waitpid() failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf);
> return false;
> }
> if (!WIFSTOPPED(status)) {
> printf("child did not stop\n");
> + snprintf(buf, sizeof(buf),
> + "child did not stop: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf);
> return false;
> }
> if (WSTOPSIG(status) != SIGSTOP) {
> - printf("child did not stop with SIGSTOP\n");
> + ksft_test_result_fail("child did not stop with SIGSTOP\n");
> return false;
> }
>
> @@ -140,42 +165,58 @@ 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");
> + snprintf(buf, sizeof(buf),
> + "ptrace(PTRACE_SINGLESTEP) failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf);
> return false;
> }
>
> alarm(3);
> wpid = waitpid(pid, &status, __WALL);
> if (wpid != pid) {
> - perror("waitpid() failed");
> + snprintf(buf2, sizeof(buf2),
> + "waitpid() failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf2);
> return false;
> }
> alarm(0);
> if (WIFEXITED(status)) {
> - printf("child did not single-step\t");
> + ksft_test_result_fail("child did not single-step\t");
> return false;
> }
> if (!WIFSTOPPED(status)) {
> - printf("child did not stop\n");
> + ksft_test_result_fail("child did not stop\n");
> return false;
> }
> if (WSTOPSIG(status) != SIGTRAP) {
> - printf("child did not stop with SIGTRAP\n");
> + ksft_test_result_fail("child did not stop with SIGTRAP\n");
> return false;
> }
> if (ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) {
> perror("ptrace(PTRACE_GETSIGINFO)");
> + snprintf(buf2, sizeof(buf2),
> + "ptrace(PTRACE_GETSIGINFO): %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf2);
> return false;
> }
> if (siginfo.si_code != TRAP_HWBKPT) {
> - printf("Unexpected si_code %d\n", siginfo.si_code);
> + snprintf(buf2, sizeof(buf2),
> + "Unexpected si_code %d\n",
> + siginfo.si_code);
> + ksft_test_result_fail(buf2);
> return false;
> }
>
> kill(pid, SIGKILL);
> wpid = waitpid(pid, &status, 0);
> if (wpid != pid) {
> - perror("waitpid() failed");
> + snprintf(buf2, sizeof(buf2),
> + "waitpid() failed: %s\n",
> + strerror(errno));
> + ksft_test_result_fail(buf2);
> return false;
> }
> return true;
> @@ -192,6 +233,9 @@ int main(int argc, char **argv)
> struct sigaction act;
> int wr, wp, size;
> bool result;
> + char msg_buf[512];
> +
> + ksft_print_header();
>
> act.sa_handler = sigalrm;
> sigemptyset(&act.sa_mask);
> @@ -200,14 +244,15 @@ 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);
> + snprintf(msg_buf, sizeof(msg_buf),
> + "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(msg_buf);
> + else {
> + ksft_test_result_fail(msg_buf);
> succeeded = false;
> }
> }
> @@ -215,19 +260,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();
> + snprintf(msg_buf, sizeof(msg_buf),
> + "Test size = %d write offset = %d watchpoint offset = -8\t",
> + size, -size);
> +
> + if (run_test(size, 8, -size, -8))
> + ksft_test_result_pass(msg_buf);
> + else {
> + ksft_test_result_fail(msg_buf);
> succeeded = false;
> }
> }
>
> - ksft_print_cnts();
> if (succeeded)
> ksft_exit_pass();
> else
>
I would like to remind you that all ksft_* output functions append a newline character already,
so no need to add them.

Otherwise I think this patch is good.

Thank you,

Paul

2017-06-27 16:50:36

by Paul Elder

[permalink] [raw]
Subject: Re: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

On 06/28/2017 01:36 AM, Shuah Khan wrote:
> On 06/27/2017 10:11 AM, Greg KH wrote:
>> On Tue, Jun 27, 2017 at 10:04:47AM -0600, Shuah Khan wrote:
>>> Convert breakpoint_test_arm64 output to TAP13 format.
>>>
>>> Signed-off-by: Shuah Khan <[email protected]>
>>> ---
>>> .../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
>>> 1 file changed, 79 insertions(+), 35 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>> index fa6d57af5217..d13bd0dea13e 100644
>>> --- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>> +++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>> @@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
>>> static void child(int size, int wr)
>>> {
>>> volatile uint8_t *addr = &var[32 + wr];
>>> + char msg_buf[512];
>>>
>>> if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
>>> - perror("ptrace(PTRACE_TRACEME) failed");
>>> - _exit(1);
>>> + snprintf(msg_buf, sizeof(msg_buf),
>>> + "ptrace(PTRACE_TRACEME) failed: %s\n",
>>> + strerror(errno));
>>> + ksft_exit_fail_msg(msg_buf);
>>
>> No objection to this patch, but perhaps the "msg" functions could either
>> be variable arg macros, or just a printk() like function that can take
>> the string and anything you want to send to it.
>
> Right. Changing "msg" functions to take var args will make things easier.
> I will take care of that and use this test for a use-case.
I was going to work on this...
Do you want to take care of it or can I do it?

Thank you,

Paul

>>
>> So this could be:
>> ksft_exit_fail_msg("ptrace(PTRACE_TRACEME) failed: %s\n", strerror(errno));
>
> Right.
>
>>
>> Anyway, just a thought, might make conversions a lot easier, no need for
>> intermediate buffers>
>> thanks,
>>
>> greg k-h
>>
>
> thanks,
> -- Shuah
>

2017-06-27 16:53:33

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] selftests: breakpoints: convert breakpoint_test_arm64 test to TAP13

On 06/27/2017 10:50 AM, Paul Elder wrote:
> On 06/28/2017 01:36 AM, Shuah Khan wrote:
>> On 06/27/2017 10:11 AM, Greg KH wrote:
>>> On Tue, Jun 27, 2017 at 10:04:47AM -0600, Shuah Khan wrote:
>>>> Convert breakpoint_test_arm64 output to TAP13 format.
>>>>
>>>> Signed-off-by: Shuah Khan <[email protected]>
>>>> ---
>>>> .../selftests/breakpoints/breakpoint_test_arm64.c | 114 ++++++++++++++-------
>>>> 1 file changed, 79 insertions(+), 35 deletions(-)
>>>>
>>>> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>>> index fa6d57af5217..d13bd0dea13e 100644
>>>> --- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>>> +++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
>>>> @@ -41,20 +41,27 @@ static volatile uint8_t var[96] __attribute__((__aligned__(32)));
>>>> static void child(int size, int wr)
>>>> {
>>>> volatile uint8_t *addr = &var[32 + wr];
>>>> + char msg_buf[512];
>>>>
>>>> if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) {
>>>> - perror("ptrace(PTRACE_TRACEME) failed");
>>>> - _exit(1);
>>>> + snprintf(msg_buf, sizeof(msg_buf),
>>>> + "ptrace(PTRACE_TRACEME) failed: %s\n",
>>>> + strerror(errno));
>>>> + ksft_exit_fail_msg(msg_buf);
>>>
>>> No objection to this patch, but perhaps the "msg" functions could either
>>> be variable arg macros, or just a printk() like function that can take
>>> the string and anything you want to send to it.
>>
>> Right. Changing "msg" functions to take var args will make things easier.
>> I will take care of that and use this test for a use-case.
> I was going to work on this...

Yeah. Thanks for the reminder. I suggested making these var args and did as
you to do this already.

> Do you want to take care of it or can I do it?

Please take care of it. I will do the breakpoints_test_arm64 on top of
yours.

thanks,
-- Shuah

>
> Thank you,
>
> Paul
>
>>>
>>> So this could be:
>>> ksft_exit_fail_msg("ptrace(PTRACE_TRACEME) failed: %s\n", strerror(errno));
>>
>> Right.
>>
>>>
>>> Anyway, just a thought, might make conversions a lot easier, no need for
>>> intermediate buffers>
>>> thanks,
>>>
>>> greg k-h
>>>
>>
>> thanks,
>> -- Shuah
>>