Re: [PATCH 1/4] kselftest: add TAP13 conformant versions of ksft_* functions

[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>
> 
> Add TAP13 conformat output functions to kselftest.h, while preserving
> the old ksft_* output functions to allow backwards compatability.

Let's just change the existing ones instead of adding _tap variations.
There aren't many uses of existing ones to warrant preserving old ones.
Having two variants is confusing and I would favor obsoleting the old
ones anyway. Might as well do it now.

> 
> Also add exit functions that output TAP13 exiting text, as well as
> functions to keep track of testing progress.
> 
> 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>
> ---
>  tools/testing/selftests/kselftest.h | 77 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 77 insertions(+)
> 
> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> index ef1c80d67ac7..c1a4599884c4 100644
> --- a/tools/testing/selftests/kselftest.h
> +++ b/tools/testing/selftests/kselftest.h
> @@ -31,12 +31,24 @@ struct ksft_count {
>  
>  static struct ksft_count ksft_cnt;
>  
> +static inline int ksft_test_num(void)
> +{
> +	return ksft_cnt.ksft_pass + ksft_cnt.ksft_fail +
> +		ksft_cnt.ksft_xfail + ksft_cnt.ksft_xpass +
> +		ksft_cnt.ksft_xskip;
> +}

Nice way to derive test number. I am glad the existing API worked
as a good base.

> +
>  static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
>  static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
>  static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
>  static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
>  static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
>  
> +static inline void ksft_print_tap_header(void)
> +{
> +	printf("TAP version 13\n");
> +}
> +
>  static inline void ksft_print_cnts(void)
>  {
>  	printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n",
> @@ -45,25 +57,90 @@ static inline void ksft_print_cnts(void)
>  		ksft_cnt.ksft_xskip);
>  }
>  
> +static inline void ksft_print_cnts_tap(void)
> +{
> +	printf("1..%d\n", ksft_test_num());
> +}
> +

Let's change ksft_print_cnts() instead of adding a new
one. Looking at the existing usage of this API, it is fine to
go that route.

There are really two users of this at the moment breakpoints
and kcmp. This patch series is updating breakpoints anyway.
So we just have kcmp to update, I can do that.

> +static inline void ksft_test_result_pass(const char *msg)
> +{
> +	ksft_cnt.ksft_pass++;
> +	printf("ok %d %s\n", ksft_test_num(), msg);
> +}
> +
> +static inline void ksft_test_result_fail(const char *msg)
> +{
> +	ksft_cnt.ksft_fail++;
> +	printf("not ok %d %s\n", ksft_test_num(), msg);
> +}
> +
> +static inline void ksft_test_result_skip(const char *msg)
> +{
> +	ksft_cnt.ksft_xskip++;
> +	printf("ok %d # skip %s\n", ksft_test_num(), msg);
> +}
> +
>  static inline int ksft_exit_pass(void)
>  {
>  	exit(KSFT_PASS);
>  }
> +
> +static inline int ksft_exit_pass_tap(void)
> +{
> +	ksft_print_cnts_tap();
> +	exit(KSFT_PASS);
> +}

Let's change ksft_exit_pass() instead of adding a new one.
I think there a few more tests that use this one, however
printing counts at exit won't hurt the test really. Counts
might be incorrect depending on whether the test is incrementing
counts or not, but that would be easy to fix.

So I would prefer fixing minor issues that might come up by changing
existing API over adding new API - all of the tests need update
anyway.

> +
>  static inline int ksft_exit_fail(void)
>  {
>  	exit(KSFT_FAIL);
>  }
> +
> +static inline int ksft_exit_fail_tap(void)
> +{
> +	printf("Bail out!\n");
> +	ksft_print_cnts_tap();
> +	exit(KSFT_FAIL);
> +}
> +

Let's change ksft_exit_fail() instead of adding a new one.

> +static inline int ksft_exit_fail_tap_msg(const char *msg)
> +{
> +	printf("Bail out! %s\n", msg);
> +	ksft_print_cnts_tap();
> +	exit(KSFT_FAIL);
> +}
> +
>  static inline int ksft_exit_xfail(void)
>  {
>  	exit(KSFT_XFAIL);
>  }
> +

> +static inline int ksft_exit_xfail_tap(void)
> +{
> +	ksft_print_cnts_tap();
> +	exit(KSFT_XFAIL);
> +}
> +

Let's change ksft_exit_xfail() instead of adding a new one.

>  static inline int ksft_exit_xpass(void)
>  {
>  	exit(KSFT_XPASS);
>  }
> +

> +static inline int ksft_exit_xpass_tap(void)
> +{
> +	ksft_print_cnts_tap();
> +	exit(KSFT_XPASS);
> +}
> +

Let's change ksft_exit_xpass() instead of adding a new one.

>  static inline int ksft_exit_skip(void)
>  {
>  	exit(KSFT_SKIP);
>  }
>  
> +static inline int ksft_exit_skip_tap(void)
> +{
> +	ksft_print_cnts_tap();
> +	exit(KSFT_SKIP);
> +}

Let's change ksft_exit_skip() instead of adding a new one.

> +
>  #endif /* __KSELFTEST_H */
> 

thanks,
-- Shuah
--
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