On 06/14/2017 04:50 AM, Shuah Khan wrote: > On 06/13/2017 01:05 PM, Alice Ferrazzi wrote: >> >> >> On Wed, Jun 14, 2017 at 3:52 AM, Shuah Khan <shuah@xxxxxxxxxx <mailto:shuah@xxxxxxxxxx>> wrote: >> >> Hi Paul, >> >> On 06/13/2017 11:54 AM, Paul Elder wrote: >> > On 06/12/2017 03:56 PM, Greg Kroah-Hartman wrote: >> >> From: Paul Elder <paul.elder@xxxxxxxx <mailto:paul.elder@xxxxxxxx>> >> >> >> >> Add TAP13 conformat output functions to kselftest.h. >> >> >> >> Also add exit functions that output TAP13 exiting text, as well as >> >> functions to keep track of testing progress. >> >> >> >> Signed-off-by: Paul Elder <paul.elder@xxxxxxxx <mailto:paul.elder@xxxxxxxx>> >> >> Signed-off-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx <mailto:alice.ferrazzi@xxxxxxxxx>> >> >> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx <mailto:gregkh@xxxxxxxxxxxxxxxxxxx>> >> >> --- >> >> v2: Just use the standard function names, no _tap suffix - Alice >> >> >> >> tools/testing/selftests/kselftest.h | 52 ++++++++++++++++++++++++++++++++++--- >> >> 1 file changed, 48 insertions(+), 4 deletions(-) >> >> >> >> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h >> >> index ef1c80d67ac7..1d874a50d957 100644 >> >> --- a/tools/testing/selftests/kselftest.h >> >> +++ b/tools/testing/selftests/kselftest.h >> >> @@ -31,38 +31,82 @@ 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; >> >> +} >> >> + >> >> 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_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", >> >> - ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, >> >> - ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass, >> >> - ksft_cnt.ksft_xskip); >> >> + printf("1..%d\n", ksft_test_num()); >> >> +} >> >> + >> >> +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); >> >> } >> > >> > I just realized; the test count increments within the these three functions >> > (the ksft_test_result_* functions) should use the actual incrementor function >> > calls (ksft_inc_*_cnt) instead of directly incrementing them, shouldn't they? >> >> I added the increment functions for flexibility. If a test >> chooses to increment individual pass/fail/xfai/xpass counts >> and then print summary. I see. So it's fine then to increment these directly? >> > >> > Although I suppose it's readable enough that it's fine >> > >> > As far as I can tell as long as we have these ksft_test_result_* functions >> > that increment the test count *and* output the test result, the incrementor >> > functions aren't going to be used a lot, if ever. >> > >> > Thoughts? >> > >> > Also what's the difference between fail/xfail and pass/xpass? >> >> xfail means that the test ix expected to fail but passed >> xpass means that the test is expected pass, but failed. I see. Thank you. >> >> >> With TAP 13 output there is no xfail or xpass format. >> >> Is probably like >> ok 1 Correctly failed >> >> This mean that we can think to remove xfail and xpass ? Exactly what I was thinking as well. > Possibly - We can make that call later on whetherto remove or not. Thank you, Paul > > -- Shuah >> >> >> >> thanks, >> -- Shuah >> > >> > Thank you, >> > >> > Paul >> > >> >> static inline int ksft_exit_pass(void) >> >> { >> >> + ksft_print_cnts(); >> >> exit(KSFT_PASS); >> >> } >> >> + >> >> static inline int ksft_exit_fail(void) >> >> { >> >> + printf("Bail out!\n"); >> >> + ksft_print_cnts(); >> >> exit(KSFT_FAIL); >> >> } >> >> + >> >> +static inline int ksft_exit_fail_msg(const char *msg) >> >> +{ >> >> + printf("Bail out! %s\n", msg); >> >> + ksft_print_cnts(); >> >> + exit(KSFT_FAIL); >> >> +} >> >> + >> >> static inline int ksft_exit_xfail(void) >> >> { >> >> + ksft_print_cnts(); >> >> exit(KSFT_XFAIL); >> >> } >> >> + >> >> static inline int ksft_exit_xpass(void) >> >> { >> >> + ksft_print_cnts(); >> >> exit(KSFT_XPASS); >> >> } >> >> + >> >> static inline int ksft_exit_skip(void) >> >> { >> >> + ksft_print_cnts(); >> >> exit(KSFT_SKIP); >> >> } >> >> >> >> >> > >> > >> >> >> thanks, >> Alice >> >> -- >> アリス フェッラッツィ >> Alice Ferrazzi >> >> Gentoo Kernel Project Leader >> Mail: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx <mailto:alice.ferrazzi@xxxxxxxxx>> >> PGP: 2E4E 0856 461C 0585 1336 F496 5621 A6B2 8638 781A > -- 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