Re: [PATCH 3/4] kselftest: breakpoints: convert breakpoint_test to TAP13 output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/09/2017 02:23 AM, Greg Kroah-Hartman wrote:
> From: Paul Elder <paul.elder@xxxxxxxx>
> 
> Make the breakpoints test output in the TAP13 format by using the
> TAP13 output functions defined in kselftest.h
> 
> Cc: Tim Bird <Tim.Bird@xxxxxxxx>
> Signed-off-by: Paul Elder <paul.elder@xxxxxxxx>
> Signed-off-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
>  .../selftests/breakpoints/breakpoint_test.c        | 31 +++++++++++-----------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c
> index 120895ab5505..808328a854e2 100644
> --- a/tools/testing/selftests/breakpoints/breakpoint_test.c
> +++ b/tools/testing/selftests/breakpoints/breakpoint_test.c
> @@ -42,10 +42,8 @@ static void set_breakpoint_addr(void *addr, int n)
>  
>  	ret = ptrace(PTRACE_POKEUSER, child_pid,
>  		     offsetof(struct user, u_debugreg[n]), addr);
> -	if (ret) {
> -		perror("Can't set breakpoint addr\n");
> -		ksft_exit_fail();
> -	}
> +	if (ret)
> +		ksft_exit_fail_tap_msg("Can't set breakpoint addr");
>  }

Adding test name to the output would be helpful. Applies to all output
messages in this patch.

thanks,
-- Shuah

>  
>  static void toggle_breakpoint(int n, int type, int len,
> @@ -105,10 +103,8 @@ static void toggle_breakpoint(int n, int type, int len,
>  
>  	ret = ptrace(PTRACE_POKEUSER, child_pid,
>  		     offsetof(struct user, u_debugreg[7]), dr7);
> -	if (ret) {
> -		perror("Can't set dr7");
> -		ksft_exit_fail();
> -	}
> +	if (ret)
> +		ksft_exit_fail_tap_msg("Can't set dr7");
>  }
>  
>  /* Dummy variables to test read/write accesses */
> @@ -264,26 +260,29 @@ static void check_success(const char *msg)
>  	const char *msg2;
>  	int child_nr_tests;
>  	int status;
> +	int ret;
>  
>  	/* Wait for the child to SIGTRAP */
>  	wait(&status);
>  
>  	msg2 = "Failed";
> +	ret = 0;
>  
>  	if (WSTOPSIG(status) == SIGTRAP) {
>  		child_nr_tests = ptrace(PTRACE_PEEKDATA, child_pid,
>  					&nr_tests, 0);
>  		if (child_nr_tests == nr_tests)
> -			msg2 = "Ok";
> -		if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1)) {
> -			perror("Can't poke\n");
> -			ksft_exit_fail();
> -		}
> +			ret = 1;
> +		if (ptrace(PTRACE_POKEDATA, child_pid, &trapped, 1))
> +			ksft_exit_fail_tap_msg("Can't poke");
>  	}
>  
>  	nr_tests++;
>  
> -	printf("%s [%s]\n", msg, msg2);
> +	if (ret)
> +		ksft_test_result_pass(msg);
> +	else
> +		ksft_test_result_fail(msg);
>  }
>  
>  static void launch_instruction_breakpoints(char *buf, int local, int global)
> @@ -378,6 +377,8 @@ int main(int argc, char **argv)
>  	pid_t pid;
>  	int ret;
>  
> +	ksft_print_tap_header();
> +
>  	pid = fork();
>  	if (!pid) {
>  		trigger_tests();
> @@ -392,5 +393,5 @@ int main(int argc, char **argv)
>  
>  	wait(NULL);
>  
> -	return ksft_exit_pass();
> +	return ksft_exit_pass_tap();
>  }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux