All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros
Date: Thu, 25 Apr 2024 13:40:13 +0200	[thread overview]
Message-ID: <20240425114013.GA284406@pevik> (raw)
In-Reply-To: <20240425020308.25367-2-wegao@suse.com>

Hi Wei,

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------
>  1 file changed, 39 insertions(+), 6 deletions(-)

> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 22b39fb14..1fb133dd3 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -178,6 +178,28 @@ extern void *TST_RET_PTR;
>                                                                                 \
>  	} while (0)

> +#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...)             \
> +	do {                                                                   \
> +		TESTPTR(SCALL);                                                \
> +		                                                               \
> +		TST_PASS = 0;                                                  \
> +		                                                               \
> +		if (TST_RET_PTR == FAIL_PTR_VAL) {                             \
> +			TST_MSG_(TFAIL | TTERRNO, " failed",                   \
> +			         SSCALL, ##__VA_ARGS__);                       \
> +		        break;                                                 \
> +		}                                                              \
> +		                                                               \
> +		if (TST_RET != 0) {                                            \
> +			TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld",      \
> +			          TST_RET, SSCALL, ##__VA_ARGS__);             \
> +			break;                                                 \
> +		}                                                              \
> +                                                                               \
> +		TST_PASS = 1;                                                  \
> +                                                                               \
> +	} while (0)
> +
>  #define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, #SCALL, ##__VA_ARGS__)

>  #define TST_EXP_PASS(SCALL, ...)                                               \
> @@ -188,6 +210,21 @@ extern void *TST_RET_PTR;
>  			TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
>  	} while (0)                                                            \

> +#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...)                    \
> +	do {                                                                   \
> +		TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL,                        \
> +					FAIL_PTR_VAL, ##__VA_ARGS__);          \
> +		                                                               \
> +		if (TST_PASS)                                                  \
> +			TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
> +	} while (0)
> +
> +#define TST_EXP_PASS_PTR_NULL(SCALL, ...)                                      \
> +               TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__);

I'm still not sure whether add TST_EXP_PASS_PTR_NULL, which is not used.
I wonder what others think (it can be removed before merge).

> +
> +#define TST_EXP_PASS_PTR_VOID(SCALL, ...)                                      \
> +               TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__);
> +
>  /*
>   * Returns true if err is in the exp_err array.
>   */
> @@ -301,10 +338,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
>  	} while (0)

>  #define TST_EXP_FAIL_PTR_NULL_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)      \
> -	do {                                                                   \
>  		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
> -			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);        \
> -	} while (0)
> +			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);
+1

>  #define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                         \
>  	do {                                                                   \
> @@ -314,10 +349,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
>  	} while (0)

>  #define TST_EXP_FAIL_PTR_VOID_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)      \
> -	do {                                                                   \
>  		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
> -			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);        \
> -	} while (0)
> +			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);
+1

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

>  #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
>  	do {                                                                   \

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-04-25 11:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  2:51 [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros Wei Gao via ltp
2024-04-17  8:31 ` Petr Vorel
2024-04-25  2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp
2024-04-25  2:03   ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp
2024-04-25 11:40     ` Petr Vorel [this message]
2024-04-29 17:51       ` [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Avinesh Kumar
2024-04-25  2:03   ` [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID Wei Gao via ltp
2024-04-25 11:42     ` Petr Vorel
2024-04-25  2:03   ` [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
2024-04-25 11:44     ` Petr Vorel
2025-01-14 13:42   ` [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240425114013.GA284406@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.