RE: [PATCH v2 4/4] kselftest: breakpoints: convert step_after_suspend_test to TAP13 output

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

 



> -----Original Message-----
> From: Greg Kroah-Hartman on Monday, June 12, 2017 3:57 PM
>
> 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@xxxxxxxx>
> Signed-off-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> v2: Just use the standard function names, no _tap suffix - Alice
> 
> 
>  .../breakpoints/step_after_suspend_test.c          | 43 +++++++++-------------
>  1 file changed, 17 insertions(+), 26 deletions(-)
> 
> diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
> b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
> index 60b8a95dac26..bf37c1087f25 100644
> --- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
> +++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
> @@ -135,28 +135,21 @@ void suspend(void)
>  	struct itimerspec spec = {};
> 
>  	power_state_fd = open("/sys/power/state", O_RDWR);
> -	if (power_state_fd < 0) {
> -		perror("open(\"/sys/power/state\") failed (is this test
> running as root?)");
> -		ksft_exit_fail();
> -	}
> +	if (power_state_fd < 0)
> +		ksft_exit_fail_msg(
> +			"open(\"/sys/power/state\") failed (is this test
> running as root?)");
> 
>  	timerfd = timerfd_create(CLOCK_BOOTTIME_ALARM, 0);
> -	if (timerfd < 0) {
> -		perror("timerfd_create() failed");
> -		ksft_exit_fail();
> -	}
> +	if (timerfd < 0)
> +		ksft_exit_fail_msg("timerfd_create() failed");
> 
>  	spec.it_value.tv_sec = 5;
>  	err = timerfd_settime(timerfd, 0, &spec, NULL);
> -	if (err < 0) {
> -		perror("timerfd_settime() failed");
> -		ksft_exit_fail();
> -	}
> +	if (err < 0)
> +		ksft_exit_fail_msg("timerfd_settime() failed");
> 
> -	if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
> {
> -		perror("entering suspend failed");
> -		ksft_exit_fail();
> -	}
> +	if (write(power_state_fd, "mem", strlen("mem")) != strlen("mem"))
> +		ksft_exit_fail_msg("entering suspend failed");
> 
>  	close(timerfd);
>  	close(power_state_fd);
> @@ -170,6 +163,9 @@ int main(int argc, char **argv)
>  	cpu_set_t available_cpus;
>  	int err;
>  	int cpu;
> +	char buf[10];
> +
> +	ksft_print_header();
> 
>  	while ((opt = getopt(argc, argv, "n")) != -1) {
>  		switch (opt) {
> @@ -187,10 +183,8 @@ int main(int argc, char **argv)
>  		suspend();
> 
>  	err = sched_getaffinity(0, sizeof(available_cpus), &available_cpus);
> -	if (err < 0) {
> -		perror("sched_getaffinity() failed");
> -		ksft_exit_fail();
> -	}
> +	if (err < 0)
> +		ksft_exit_fail_msg("sched_getaffinity() failed");
> 
>  	for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
>  		bool test_success;
> @@ -199,18 +193,15 @@ int main(int argc, char **argv)
>  			continue;
> 
>  		test_success = run_test(cpu);
> -		printf("CPU %d: ", cpu);
> +		sprintf(buf, "CPU %d", cpu);
>  		if (test_success) {
> -			printf("[OK]\n");
> -			ksft_inc_pass_cnt();
> +			ksft_test_result_pass(buf);
If you follow my recommendations for patch 1/4, this becomes:
ksft_pass(buf);

>  		} else {
> -			printf("[FAILED]\n");
> -			ksft_inc_fail_cnt();
> +			ksft_test_result_fail(buf);
Since the failure string really adds no value, I would not pass a reason string here.
It's redundant with the TAP test result output (ok|not ok).

ksft_fail(buf, NULL);

>  			succeeded = false;
>  		}
>  	}
> 
> -	ksft_print_cnts();
>  	if (succeeded)
>  		ksft_exit_pass();
>  	else
> --
> 2.13.1
> 

--
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