* [LTP] [PATCH 0/2] lib: Add TINFO_WARN
@ 2024-05-27 22:29 Petr Vorel
2024-05-27 22:29 ` [LTP] [PATCH 1/2] " Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Petr Vorel @ 2024-05-27 22:29 UTC (permalink / raw)
To: ltp
Hi,
if we found this useful, is it worth to implement it also in the shell
API?
Regardless the result, should it be TDEBUG backported to the shell API?
Kind regards,
Petr
Petr Vorel (2):
lib: Add TINFO_WARN
tree: Use TINFO_WARN
include/tst_res_flags.h | 6 +++++-
include/tst_test.h | 2 +-
lib/newlib_tests/tst_res_flags.c | 1 +
lib/tst_ansi_color.c | 1 +
lib/tst_res.c | 12 ++++++++----
lib/tst_supported_fs_types.c | 2 +-
lib/tst_test.c | 3 +++
testcases/kernel/mem/hugetlb/lib/hugetlb.c | 4 ++--
testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +-
9 files changed, 23 insertions(+), 10 deletions(-)
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* [LTP] [PATCH 1/2] lib: Add TINFO_WARN 2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel @ 2024-05-27 22:29 ` Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel 2024-05-28 6:04 ` [LTP] [PATCH 0/2] lib: Add TINFO_WARN Andrea Cervesato via ltp 2 siblings, 0 replies; 13+ messages in thread From: Petr Vorel @ 2024-05-27 22:29 UTC (permalink / raw) To: ltp When replaced tst_res(TINFO, "WARNING: ...") with tst_res(TINFO_WARN, "..."), then: - output message is magenta (the same as for TWARN => more visible), - "WARNING" is printed by the library (unification), Signed-off-by: Petr Vorel <pvorel@suse.cz> --- include/tst_res_flags.h | 6 +++++- include/tst_test.h | 2 +- lib/newlib_tests/tst_res_flags.c | 1 + lib/tst_ansi_color.c | 1 + lib/tst_res.c | 12 ++++++++---- lib/tst_test.c | 3 +++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/tst_res_flags.h b/include/tst_res_flags.h index 806940e0d..bb2f38c93 100644 --- a/include/tst_res_flags.h +++ b/include/tst_res_flags.h @@ -22,6 +22,9 @@ * @TINFO: Prints an additional information, it does not change the test result * counters but unlike TDEBUG the message is always displayed. * + * @TINFO_WARN: Reports a single warning, but it does not change the test result + * counters like TINFO. + * * @TCONF: Reports unsupported configuration. When tests produce this result at * least a subset of test was skipped, because it couldn't run. The * usual reasons are, missing kernel modules or CONFIG options. @@ -55,12 +58,13 @@ enum tst_res_flags { TDEBUG = 8, TINFO = 16, TCONF = 32, + TINFO_WARN = 64, TERRNO = 0x100, TTERRNO = 0x200, TRERRNO = 0x400, }; #define TTYPE_RESULT(ttype) ((ttype) & TTYPE_MASK) -#define TTYPE_MASK 0x3f +#define TTYPE_MASK 0x7f #endif /* TST_RES_FLAGS_H */ diff --git a/include/tst_test.h b/include/tst_test.h index 8dc20d110..6c1f7bce1 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -69,7 +69,7 @@ void tst_res_(const char *file, const int lineno, int ttype, ({ \ TST_RES_SUPPORTS_TCONF_TDEBUG_TFAIL_TINFO_TPASS_TWARN(\ !((TTYPE_RESULT(ttype) ?: TCONF) & \ - (TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN))); \ + (TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN | TINFO_WARN))); \ tst_res_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\ }) diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c index a14f0df2c..7d3bc3785 100644 --- a/lib/newlib_tests/tst_res_flags.c +++ b/lib/newlib_tests/tst_res_flags.c @@ -20,6 +20,7 @@ static struct tcase { {FLAG(TBROK)}, {FLAG(TCONF)}, {FLAG(TWARN)}, + {FLAG(TINFO_WARN)}, {FLAG(TINFO)}, {FLAG(TDEBUG), " (printed only with -D or LTP_ENABLE_DEBUG=1)"}, }; diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c index 98041c0af..7d1dca516 100644 --- a/lib/tst_ansi_color.c +++ b/lib/tst_ansi_color.c @@ -26,6 +26,7 @@ char* tst_ttype2color(int ttype) return ANSI_COLOR_YELLOW; break; case TWARN: + case TINFO_WARN: return ANSI_COLOR_MAGENTA; break; case TINFO: diff --git a/lib/tst_res.c b/lib/tst_res.c index 7c66d2f6c..d28c0b4f4 100644 --- a/lib/tst_res.c +++ b/lib/tst_res.c @@ -174,13 +174,16 @@ static void tst_res__(const char *file, const int lineno, int ttype, int len = 0; int ttype_result = TTYPE_RESULT(ttype); - if (ttype_result == TDEBUG) { - printf("%s: %i: TDEBUG is not supported\n", __func__, __LINE__); + if (ttype_result == TDEBUG || ttype_result == TINFO_WARN) { + printf("%s: %i: %s is not supported\n", __func__, __LINE__, + strttype(ttype)); abort(); } - if (file && (ttype_result != TPASS && ttype_result != TINFO)) + if (file && (ttype_result != TPASS && ttype_result != TINFO + && ttype_result != TINFO_WARN)) { len = sprintf(tmesg, "%s:%d: ", file, lineno); + } EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len); /* @@ -198,7 +201,8 @@ static void tst_res__(const char *file, const int lineno, int ttype, * Set the test case number and print the results, depending on the * display type. */ - if (ttype_result == TWARN || ttype_result == TINFO) { + if (ttype_result == TWARN || ttype_result == TINFO || + ttype_result == TINFO_WARN) { tst_print(TCID, 0, ttype, tmesg); } else { if (tst_count < 0) diff --git a/lib/tst_test.c b/lib/tst_test.c index 8c212c983..ef5148c0f 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -225,6 +225,9 @@ static void print_result(const char *file, const int lineno, int ttype, case TINFO: res = "TINFO"; break; + case TINFO_WARN: + res = "TINFO WARNING"; + break; case TDEBUG: res = "TDEBUG"; break; -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [LTP] [PATCH 2/2] tree: Use TINFO_WARN 2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 1/2] " Petr Vorel @ 2024-05-27 22:29 ` Petr Vorel 2024-05-28 6:04 ` [LTP] [PATCH 0/2] lib: Add TINFO_WARN Andrea Cervesato via ltp 2 siblings, 0 replies; 13+ messages in thread From: Petr Vorel @ 2024-05-27 22:29 UTC (permalink / raw) To: ltp Signed-off-by: Petr Vorel <pvorel@suse.cz> --- lib/tst_supported_fs_types.c | 2 +- testcases/kernel/mem/hugetlb/lib/hugetlb.c | 4 ++-- testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c index bbbb8df19..8b8cf213a 100644 --- a/lib/tst_supported_fs_types.c +++ b/lib/tst_supported_fs_types.c @@ -158,7 +158,7 @@ const char **tst_get_supported_fs_types(const char *const *skiplist) only_fs = getenv("LTP_SINGLE_FS_TYPE"); if (only_fs) { - tst_res(TINFO, "WARNING: testing only %s", only_fs); + tst_res(TINFO_WARN, "testing only %s", only_fs); if (tst_fs_is_supported(only_fs)) fs_types[0] = only_fs; return fs_types; diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c index 43a677ce9..c612bf2d2 100644 --- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c +++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c @@ -106,8 +106,8 @@ void rm_shm(int shm_id) * check for # of attaches ? */ if (shmctl(shm_id, IPC_RMID, NULL) == -1) { - tst_res(TINFO, "WARNING: shared memory deletion failed."); - tst_res(TINFO, "This could lead to IPC resource problems."); + tst_res(TINFO_WARN, "shared memory deletion failed"); + tst_res(TINFO, "This could lead to IPC resource problems"); tst_res(TINFO, "id = %d", shm_id); } } diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl08.c b/testcases/kernel/syscalls/ipc/semctl/semctl08.c index 1878bd49d..aacdcf6a5 100644 --- a/testcases/kernel/syscalls/ipc/semctl/semctl08.c +++ b/testcases/kernel/syscalls/ipc/semctl/semctl08.c @@ -40,7 +40,7 @@ static void run(void) tst_res(TPASS, "time_high fields cleared by the kernel"); if (semctl(semid, 0, IPC_RMID, arg) == -1) - tst_res(TINFO, "WARNING: semaphore deletion failed."); + tst_res(TINFO_WARN, "semaphore deletion failed"); } static struct tst_test test = { -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 1/2] " Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel @ 2024-05-28 6:04 ` Andrea Cervesato via ltp 2024-05-29 15:10 ` Cyril Hrubis 2 siblings, 1 reply; 13+ messages in thread From: Andrea Cervesato via ltp @ 2024-05-28 6:04 UTC (permalink / raw) To: ltp Hi! I'm not sure about this. Why not enabling TINFO + TWARN combination instead? tst_res(TINFO | TWARN, "my message"); On 5/28/24 00:29, Petr Vorel wrote: > Hi, > > if we found this useful, is it worth to implement it also in the shell > API? > > Regardless the result, should it be TDEBUG backported to the shell API? > > Kind regards, > Petr > > Petr Vorel (2): > lib: Add TINFO_WARN > tree: Use TINFO_WARN > > include/tst_res_flags.h | 6 +++++- > include/tst_test.h | 2 +- > lib/newlib_tests/tst_res_flags.c | 1 + > lib/tst_ansi_color.c | 1 + > lib/tst_res.c | 12 ++++++++---- > lib/tst_supported_fs_types.c | 2 +- > lib/tst_test.c | 3 +++ > testcases/kernel/mem/hugetlb/lib/hugetlb.c | 4 ++-- > testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +- > 9 files changed, 23 insertions(+), 10 deletions(-) > Andrea -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-05-28 6:04 ` [LTP] [PATCH 0/2] lib: Add TINFO_WARN Andrea Cervesato via ltp @ 2024-05-29 15:10 ` Cyril Hrubis 2024-06-20 5:36 ` Petr Vorel 0 siblings, 1 reply; 13+ messages in thread From: Cyril Hrubis @ 2024-05-29 15:10 UTC (permalink / raw) To: Andrea Cervesato; +Cc: ltp Hi! > I'm not sure about this. Why not enabling TINFO + TWARN combination instead? > > tst_res(TINFO | TWARN, "my message"); That's even more confusing. Does that propagate into results or not? To be honest we even have problem deciding if we should use TINFO or TWARN in some cases and adding third variant would make things even worse, sicne we would have three options. So I would really keep just TINFO which is something that is printed by default but does not propagate into results and TWARN that is printed as well but propagates into results. Maybe it would be even better to actually remove TWARN. That way we would have only TFAIL and TBROK that propagate into results since TWARN is kind of lesser TBROK anyways... -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-05-29 15:10 ` Cyril Hrubis @ 2024-06-20 5:36 ` Petr Vorel 2024-06-20 8:05 ` Li Wang 0 siblings, 1 reply; 13+ messages in thread From: Petr Vorel @ 2024-06-20 5:36 UTC (permalink / raw) To: Cyril Hrubis; +Cc: ltp > Hi! > > I'm not sure about this. Why not enabling TINFO + TWARN combination instead? > > tst_res(TINFO | TWARN, "my message"); > That's even more confusing. Does that propagate into results or not? > To be honest we even have problem deciding if we should use TINFO or > TWARN in some cases and adding third variant would make things even > worse, sicne we would have three options. > So I would really keep just TINFO which is something that is printed by > default but does not propagate into results and TWARN that is printed as > well but propagates into results. > Maybe it would be even better to actually remove TWARN. That way we > would have only TFAIL and TBROK that propagate into results since TWARN > is kind of lesser TBROK anyways... Understand to your points. But tst_res TWARN is quite understandable (simple warning, which propagates), IMHO better to use than tst_res TBROK. But sure, feel free to go ahead and send a patch to remove TWARN. BTW I was also surprised how many tests use tst_resm TBROK ... / tst_resm(TBROK, ...) followed by exit 1 / exit(1). These should be converted to tst_brkm TBROK / tst_resm(TBROK, ...). Other thing is, that I would prefer to have macro for tst_res(TINFO, "WARNING: ...") e.g. WARNING(...) would produce tst_res(TINFO, "WARNING: ...") from simple point I don't like to hardwire text (there can be typos). BTW more than for this rare case I would prefer to have macros for .tags, e.g. LINUX_GIT(43a6684519ab) would produce {"linux-git", "43a6684519ab"} CVE(2017-2671) would produce {"CVE", "2017-2671"} (again, typos). Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-20 5:36 ` Petr Vorel @ 2024-06-20 8:05 ` Li Wang 2024-06-20 11:25 ` Petr Vorel 2024-06-21 13:22 ` Li Wang 0 siblings, 2 replies; 13+ messages in thread From: Li Wang @ 2024-06-20 8:05 UTC (permalink / raw) To: Petr Vorel; +Cc: ltp Hi Petr, All, On Thu, Jun 20, 2024 at 1:36 PM Petr Vorel <pvorel@suse.cz> wrote: > > Hi! > > > I'm not sure about this. Why not enabling TINFO + TWARN combination > instead? > > > > tst_res(TINFO | TWARN, "my message"); > > > That's even more confusing. Does that propagate into results or not? > > > To be honest we even have problem deciding if we should use TINFO or > > TWARN in some cases and adding third variant would make things even > > worse, sicne we would have three options. > > > So I would really keep just TINFO which is something that is printed by > > default but does not propagate into results and TWARN that is printed as > > well but propagates into results. > > > Maybe it would be even better to actually remove TWARN. That way we > > would have only TFAIL and TBROK that propagate into results since TWARN > > is kind of lesser TBROK anyways... > > Understand to your points. But tst_res TWARN is quite understandable > (simple warning, which propagates), IMHO better to use than > tst_res TBROK. But sure, feel free to go ahead and send a patch to remove > TWARN. > +1 to remove TWARN. > BTW I was also surprised how many tests use tst_resm TBROK ... / > tst_resm(TBROK, > ...) followed by exit 1 / exit(1). These should be converted to tst_brkm > TBROK / > tst_resm(TBROK, ...). > > Other thing is, that I would prefer to have macro for tst_res(TINFO, > "WARNING: ...") > e.g. WARNING(...) would produce tst_res(TINFO, "WARNING: ...") from simple > point I > don't like to hardwire text (there can be typos). BTW more than for this > rare > case I would prefer to have macros for .tags, e.g. LINUX_GIT(43a6684519ab) > would > produce {"linux-git", "43a6684519ab"} CVE(2017-2671) would produce {"CVE", > "2017-2671"} > (again, typos). > What about defining new LTP macros like TST_RES_TINFO(), TST_RES_TFAIL(), ... TST_RES_WARNING(), so that we can save time on inputting the TFAIL/TINFO keywords every time? also TST_LINUX_GIT(), TST_CVE() ? -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-20 8:05 ` Li Wang @ 2024-06-20 11:25 ` Petr Vorel 2024-06-21 13:22 ` Li Wang 1 sibling, 0 replies; 13+ messages in thread From: Petr Vorel @ 2024-06-20 11:25 UTC (permalink / raw) To: Li Wang; +Cc: ltp > Hi Petr, All, > On Thu, Jun 20, 2024 at 1:36 PM Petr Vorel <pvorel@suse.cz> wrote: > > > Hi! > > > > I'm not sure about this. Why not enabling TINFO + TWARN combination > > instead? > > > > tst_res(TINFO | TWARN, "my message"); > > > That's even more confusing. Does that propagate into results or not? > > > To be honest we even have problem deciding if we should use TINFO or > > > TWARN in some cases and adding third variant would make things even > > > worse, sicne we would have three options. > > > So I would really keep just TINFO which is something that is printed by > > > default but does not propagate into results and TWARN that is printed as > > > well but propagates into results. > > > Maybe it would be even better to actually remove TWARN. That way we > > > would have only TFAIL and TBROK that propagate into results since TWARN > > > is kind of lesser TBROK anyways... > > Understand to your points. But tst_res TWARN is quite understandable > > (simple warning, which propagates), IMHO better to use than > > tst_res TBROK. But sure, feel free to go ahead and send a patch to remove > > TWARN. > +1 to remove TWARN. > > BTW I was also surprised how many tests use tst_resm TBROK ... / > > tst_resm(TBROK, > > ...) followed by exit 1 / exit(1). These should be converted to tst_brkm > > TBROK / > > tst_resm(TBROK, ...). > > Other thing is, that I would prefer to have macro for tst_res(TINFO, > > "WARNING: ...") > > e.g. WARNING(...) would produce tst_res(TINFO, "WARNING: ...") from simple > > point I > > don't like to hardwire text (there can be typos). BTW more than for this > > rare > > case I would prefer to have macros for .tags, e.g. LINUX_GIT(43a6684519ab) > > would > > produce {"linux-git", "43a6684519ab"} CVE(2017-2671) would produce {"CVE", > > "2017-2671"} > > (again, typos). > What about defining new LTP macros like > TST_RES_TINFO(), > TST_RES_TFAIL(), > ... > TST_RES_WARNING(), > so that we can save time on inputting the TFAIL/TINFO keywords every time? > also TST_LINUX_GIT(), TST_CVE() ? +1 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-20 8:05 ` Li Wang 2024-06-20 11:25 ` Petr Vorel @ 2024-06-21 13:22 ` Li Wang 2024-06-21 13:39 ` Petr Vorel 1 sibling, 1 reply; 13+ messages in thread From: Li Wang @ 2024-06-21 13:22 UTC (permalink / raw) To: Petr Vorel; +Cc: ltp Hi All, I come up with a way to define simple macros for all LTP print, especially for TFAIL we could make use of the GET_MACRO to select a specific macro implementation based on the number of arguments provided to a variadic macro. Something partly like: --- a/include/tst_test_macros.h +++ b/include/tst_test_macros.h @@ -368,4 +368,28 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); #define TST_EXP_EQ_SSZ(VAL_A, VAL_B) \ TST_EXP_EQ_(VAL_A, #VAL_A, VAL_B, #VAL_B, ssize_t, "%zi") +/*TST_RES*/ +#define TST_RES_TINFO(MESSAGE) \ + tst_res(TINFO, MESSAGE); + +#define TST_RES_TWARN(MESSAGE) \ + tst_res(TINFO, "WARNING "MESSAGE); + +#define TST_RES_TCONF(MESSAGE) \ + tst_res(TCONF, MESSAGE); + +#define TST_RES_TPASS(MESSAGE) \ + tst_res(TPASS, MESSAGE); + +#define TST_RES_TFAIL(...) \ + GET_MACRO(__VA_ARGS__, TST_RES_FAIL2, TST_RES_FAIL1)(__VA_ARGS__) + +#define GET_MACRO(_1, _2, NAME, ...) NAME + +#define TST_RES_FAIL1(MESSAGE) \ + tst_res(TFAIL, MESSAGE) + +#define TST_RES_FAIL2(flag, MESSAGE) \ + tst_res(TFAIL | flag, MESSAGE) + #endif /* TST_TEST_MACROS_H__ */ diff --git a/lib/newlib_tests/tst_res_macros.c b/lib/newlib_tests/tst_res_macros.c new file mode 100644 index 000000000..e16f3cbba --- /dev/null +++ b/lib/newlib_tests/tst_res_macros.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2024 Li Wang <liwang@redhat.com> + */ + +#include "tst_test.h" +#include "tst_res_flags.h" +#include "tst_test_macros.h" + +static void do_test(unsigned int i) +{ + TST_RES_TINFO("message"); + TST_RES_TPASS("message"); + TST_RES_TWARN("message"); + TST_RES_TFAIL("message"); + TST_RES_TFAIL(TERRNO, "message"); + TST_RES_TFAIL(TTERRNO, "message"); +} + +static struct tst_test test = { + .test_all = do_test, +}; > -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-21 13:22 ` Li Wang @ 2024-06-21 13:39 ` Petr Vorel 2024-06-21 13:47 ` Li Wang 0 siblings, 1 reply; 13+ messages in thread From: Petr Vorel @ 2024-06-21 13:39 UTC (permalink / raw) To: Li Wang; +Cc: ltp Hi Li, > Hi All, > I come up with a way to define simple macros for all LTP print, especially > for TFAIL > we could make use of the GET_MACRO to select a specific macro implementation > based on the number of arguments provided to a variadic macro. > Something partly like: > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h > @@ -368,4 +368,28 @@ const char *tst_errno_names(char *buf, const int > *exp_errs, int exp_errs_cnt); > #define TST_EXP_EQ_SSZ(VAL_A, VAL_B) \ > TST_EXP_EQ_(VAL_A, #VAL_A, VAL_B, #VAL_B, ssize_t, "%zi") > +/*TST_RES*/ > +#define TST_RES_TINFO(MESSAGE) \ > + tst_res(TINFO, MESSAGE); > + > +#define TST_RES_TWARN(MESSAGE) \ > + tst_res(TINFO, "WARNING "MESSAGE); > + > +#define TST_RES_TCONF(MESSAGE) \ > + tst_res(TCONF, MESSAGE); > + > +#define TST_RES_TPASS(MESSAGE) \ > + tst_res(TPASS, MESSAGE); > + > +#define TST_RES_TFAIL(...) \ > + GET_MACRO(__VA_ARGS__, TST_RES_FAIL2, > TST_RES_FAIL1)(__VA_ARGS__) > + > +#define GET_MACRO(_1, _2, NAME, ...) NAME > + > +#define TST_RES_FAIL1(MESSAGE) \ > + tst_res(TFAIL, MESSAGE) > + > +#define TST_RES_FAIL2(flag, MESSAGE) \ > + tst_res(TFAIL | flag, MESSAGE) > + > #endif /* TST_TEST_MACROS_H__ */ > diff --git a/lib/newlib_tests/tst_res_macros.c > b/lib/newlib_tests/tst_res_macros.c > new file mode 100644 > index 000000000..e16f3cbba > --- /dev/null > +++ b/lib/newlib_tests/tst_res_macros.c > @@ -0,0 +1,22 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (c) 2024 Li Wang <liwang@redhat.com> > + */ > + > +#include "tst_test.h" > +#include "tst_res_flags.h" > +#include "tst_test_macros.h" > + > +static void do_test(unsigned int i) > +{ > + TST_RES_TINFO("message"); > + TST_RES_TPASS("message"); > + TST_RES_TWARN("message"); > + TST_RES_TFAIL("message"); > + TST_RES_TFAIL(TERRNO, "message"); > + TST_RES_TFAIL(TTERRNO, "message"); > +} > + > +static struct tst_test test = { > + .test_all = do_test, > +}; Reviewed-by: Petr Vorel <pvorel@suse.cz> Thanks! Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-21 13:39 ` Petr Vorel @ 2024-06-21 13:47 ` Li Wang 2024-06-21 13:53 ` Petr Vorel 0 siblings, 1 reply; 13+ messages in thread From: Li Wang @ 2024-06-21 13:47 UTC (permalink / raw) To: Petr Vorel; +Cc: ltp On Fri, Jun 21, 2024 at 9:39 PM Petr Vorel <pvorel@suse.cz> wrote: > Hi Li, > > > Hi All, > > > I come up with a way to define simple macros for all LTP print, > especially > > for TFAIL > > we could make use of the GET_MACRO to select a specific macro > implementation > > based on the number of arguments provided to a variadic macro. > > > Something partly like: > > > --- a/include/tst_test_macros.h > > +++ b/include/tst_test_macros.h > > @@ -368,4 +368,28 @@ const char *tst_errno_names(char *buf, const int > > *exp_errs, int exp_errs_cnt); > > #define TST_EXP_EQ_SSZ(VAL_A, VAL_B) \ > > TST_EXP_EQ_(VAL_A, #VAL_A, VAL_B, #VAL_B, ssize_t, "%zi") > > > +/*TST_RES*/ > > +#define TST_RES_TINFO(MESSAGE) \ > > + tst_res(TINFO, MESSAGE); > > + > > +#define TST_RES_TWARN(MESSAGE) \ > > + tst_res(TINFO, "WARNING "MESSAGE); > > + > > +#define TST_RES_TCONF(MESSAGE) \ > > + tst_res(TCONF, MESSAGE); > > + > > +#define TST_RES_TPASS(MESSAGE) \ > > + tst_res(TPASS, MESSAGE); > > + > > +#define TST_RES_TFAIL(...) \ > > + GET_MACRO(__VA_ARGS__, TST_RES_FAIL2, > > TST_RES_FAIL1)(__VA_ARGS__) > > + > > +#define GET_MACRO(_1, _2, NAME, ...) NAME > > + > > +#define TST_RES_FAIL1(MESSAGE) \ > > + tst_res(TFAIL, MESSAGE) > > + > > +#define TST_RES_FAIL2(flag, MESSAGE) \ > > + tst_res(TFAIL | flag, MESSAGE) > > + > > #endif /* TST_TEST_MACROS_H__ */ > > diff --git a/lib/newlib_tests/tst_res_macros.c > > b/lib/newlib_tests/tst_res_macros.c > > new file mode 100644 > > index 000000000..e16f3cbba > > --- /dev/null > > +++ b/lib/newlib_tests/tst_res_macros.c > > @@ -0,0 +1,22 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (c) 2024 Li Wang <liwang@redhat.com> > > + */ > > + > > +#include "tst_test.h" > > +#include "tst_res_flags.h" > > +#include "tst_test_macros.h" > > + > > +static void do_test(unsigned int i) > > +{ > > + TST_RES_TINFO("message"); > > + TST_RES_TPASS("message"); > > + TST_RES_TWARN("message"); > > + TST_RES_TFAIL("message"); > > + TST_RES_TFAIL(TERRNO, "message"); > > + TST_RES_TFAIL(TTERRNO, "message"); > > +} > > + > > +static struct tst_test test = { > > + .test_all = do_test, > > +}; > > Reviewed-by: Petr Vorel <pvorel@suse.cz> > Thanks! > Thank you so much. Note: Basically, the method works well, but contains a tiny issue that people sometimes need to print variable value in tst_res(, "val = %d", val), so it still needs refined code to resolve that. I will send out a full support patch after testing good on my side. (maybe tomorrow). -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH 0/2] lib: Add TINFO_WARN 2024-06-21 13:47 ` Li Wang @ 2024-06-21 13:53 ` Petr Vorel 0 siblings, 0 replies; 13+ messages in thread From: Petr Vorel @ 2024-06-21 13:53 UTC (permalink / raw) To: Li Wang; +Cc: ltp Hi Li, ... > Basically, the method works well, but contains a tiny issue that people > sometimes need to print variable value in tst_res(, "val = %d", val), > so it still needs refined code to resolve that. > I will send out a full support patch after testing good on my side. > (maybe tomorrow). ... and __VA_ARGS__ see include/tst_test_macros.h #define TST_FMT_(FMT, _1, ...) FMT, ##__VA_ARGS__ Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH 0/2] lib: Add TINFO_WARN @ 2024-05-28 12:05 Petr Vorel 0 siblings, 0 replies; 13+ messages in thread From: Petr Vorel @ 2024-05-28 12:05 UTC (permalink / raw) To: ltp Hi, if we found this useful, is it worth to implement it also in the shell API? Regardless the result, should it be TDEBUG backported to the shell API? Kind regards, Petr Petr Vorel (2): lib: Add TINFO_WARN tree: Use TINFO_WARN include/tst_res_flags.h | 6 +++++- include/tst_test.h | 2 +- lib/newlib_tests/tst_res_flags.c | 1 + lib/tst_ansi_color.c | 1 + lib/tst_res.c | 12 ++++++++---- lib/tst_supported_fs_types.c | 2 +- lib/tst_test.c | 3 +++ testcases/kernel/mem/hugetlb/lib/hugetlb.c | 4 ++-- testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +- 9 files changed, 23 insertions(+), 10 deletions(-) -- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-06-21 13:54 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 1/2] " Petr Vorel 2024-05-27 22:29 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel 2024-05-28 6:04 ` [LTP] [PATCH 0/2] lib: Add TINFO_WARN Andrea Cervesato via ltp 2024-05-29 15:10 ` Cyril Hrubis 2024-06-20 5:36 ` Petr Vorel 2024-06-20 8:05 ` Li Wang 2024-06-20 11:25 ` Petr Vorel 2024-06-21 13:22 ` Li Wang 2024-06-21 13:39 ` Petr Vorel 2024-06-21 13:47 ` Li Wang 2024-06-21 13:53 ` Petr Vorel -- strict thread matches above, loose matches on Subject: below -- 2024-05-28 12:05 Petr Vorel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox