public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/3] API: TST_EXP_FAIL: Allow passing when errno is not checked
Date: Tue, 3 Aug 2021 17:31:13 +0200	[thread overview]
Message-ID: <YQlhQa/q55F98Gui@yuki> (raw)
In-Reply-To: <20210803125252.16214-1-rpalethorpe@suse.com>

Hi!
> Judging by the existing usage of TST_EXP_FAIL(..., 0, ...) in
> finit_module02. We want to pass if errno == 0 otherwise the test will
> not return a result.

This is actually not true, we do not pass 0 to TST_EXP_FAIL() in
finit_module() at all. The places that are not initialized in the
structure are initialized at runtime based on the kernel version. I do
not think that we even pass 0 to TST_EXP_FAIL*() as an errno anywhere,
but I haven't really checked all the callers.

> This is also less surprising than giving errno == 0 a dual
> meaning.

But I do agree that the current if (ERRNO) branch is confusing. I would
be for dropping the if (ERRNO) and checking the TST_ERR against ERRNO
unconditionally.

Also note that the TEST() macro clears errno, so if a syscall fails but
does not report any error TST_ERR will end up 0 either way so there is
no need for having special handling for 0.

> This also changes the trailing '\' indentation to tabs. However this
> is correct and the rest of the file is wrong.
> 
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
> 
> V3:
> * Add fix for TST_EXP_FAIL which prevented the test from
>   passing on a non buggy system.
> * TCONF but continue on non 32-bit compat mode
> * Add Fixes trailer
> 
> V2:
> * Add mising lapi header
> 
>  include/tst_test_macros.h | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 41886fbbc..4c1df58ff 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -137,17 +137,15 @@ extern void *TST_RET_PTR;
>  			break;                                                 \
>  		}                                                              \
>  		                                                               \
> -		if (ERRNO) {                                                   \
> -			if (TST_ERR == ERRNO) {                                \
> -				TST_MSG_(TPASS | TTERRNO, " ",                 \
> -				         #SCALL, ##__VA_ARGS__);               \
> -				TST_PASS = 1;                                  \
> -			} else {                                               \
> -				TST_MSGP_(TFAIL | TTERRNO, " expected %s",     \
> -				          tst_strerrno(ERRNO),                 \
> -				          #SCALL, ##__VA_ARGS__);              \
> -			}                                                      \
> -		}                                                              \
> +		if (!ERRNO || TST_ERR == ERRNO) {			\
> +			TST_MSG_(TPASS | TTERRNO, " ",			\
> +				 #SCALL, ##__VA_ARGS__);		\
> +			TST_PASS = 1;					\
> +		} else {						\
> +			TST_MSGP_(TFAIL | TTERRNO, " expected %s",	\
> +				  tst_strerrno(ERRNO),			\
> +				  #SCALL, ##__VA_ARGS__);		\
> +		}							\
>  	} while (0)
>  
>  #define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, ERRNO, __VA_ARGS__)
> -- 
> 2.31.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2021-08-03 15:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  7:05 [LTP] [PATCH] Add setsockopt08, CVE-2021-22555 Richard Palethorpe
2021-08-03  8:38 ` [LTP] [PATCH v2 1/2] Add lapi/ip_tables.h and use it in setsockopt03 Richard Palethorpe
2021-08-03  8:38   ` [LTP] [PATCH v2 2/2] Add setsockopt08, CVE-2021-22555 Richard Palethorpe
2021-08-03  8:59     ` Martin Doucha
2021-08-03  9:35       ` Richard Palethorpe
2021-08-03 12:52         ` [LTP] [PATCH v3 1/3] API: TST_EXP_FAIL: Allow passing when errno is not checked Richard Palethorpe
2021-08-03 12:52           ` [LTP] [PATCH v3 2/3] API: Add lapi/ip_tables.h and use it in setsockopt03 Richard Palethorpe
2021-08-03 12:52           ` [LTP] [PATCH v3 3/3] Add setsockopt08, CVE-2021-22555 Richard Palethorpe
2021-08-03 15:31           ` Cyril Hrubis [this message]
2021-08-05  6:37             ` [LTP] [PATCH v3 1/3] API: TST_EXP_FAIL: Allow passing when errno is not checked Richard Palethorpe
2021-08-05  8:35               ` [LTP] [PATCH v4 1/3] API: TST_EXP_FAIL: Allow passing when errno is not set Richard Palethorpe
2021-08-05  8:35                 ` [LTP] [PATCH v4 2/3] API: Add lapi/ip_tables.h and use it in setsockopt03 Richard Palethorpe
2021-08-05  8:35                 ` [LTP] [PATCH v4 3/3] Add setsockopt08, CVE-2021-22555 Richard Palethorpe
2021-08-05 14:51                   ` Cyril Hrubis
2021-08-05 15:11                     ` Cyril Hrubis
2021-08-06  7:26                       ` Richard Palethorpe
2021-08-05 13:45                 ` [LTP] [PATCH v4 1/3] API: TST_EXP_FAIL: Allow passing when errno is not set Cyril Hrubis
2021-08-05  9:34               ` [LTP] [PATCH v3 1/3] API: TST_EXP_FAIL: Allow passing when errno is not checked Cyril Hrubis

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=YQlhQa/q55F98Gui@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox