[LTP] [PATCH v1] Add TST_EXP_FAIL_PTR
Petr Vorel
pvorel@suse.cz
Tue Jan 16 18:49:26 CET 2024
Hi Wei,
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
> This is draft patch and should rebase after following patch merge.
> https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/
Patch was accepted, please rebase. Also, please add at least one test which
uses it.
Also, I wonder if we need TST_EXP_PASS_PTR().
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 3f4f9f11d..6e45e0b27 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -212,6 +212,26 @@ extern void *TST_RET_PTR;
> } \
> } while (0)
> +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...) \
> + do { \
> + TESTPTR(SCALL); \
> + \
> + TST_PASS = 0; \
> + \
> + if (TST_RET_PTR) { \
> + TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__); \
> + break; \
> + } \
> + \
> + if (TST_ERR == (ERRNO)) { \
> + TST_PASS = 1; \
> + } else { \
> + TST_MSGP_(TFAIL | TTERRNO, " expected %s", \
> + tst_strerrno(ERRNO), \
> + SSCALL, ##__VA_ARGS__); \
> + } \
Maybe follow the pattern of already used tests (break saves else clause)?
if (TST_ERR != (ERRNO)) { \
TST_MSGP_(TFAIL | TTERRNO, " expected %s", \
tst_strerrno(ERRNO), \
SSCALL, ##__VA_ARGS__); \
break; \
} \
\
TST_PASS = 1; \
> + } while (0)
> +
More information about the ltp
mailing list