public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] write05: Simplify test using TST_ macros
@ 2023-07-21 10:03 Petr Vorel
  2023-07-21 12:29 ` Avinesh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2023-07-21 10:03 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/write/write05.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/testcases/kernel/syscalls/write/write05.c b/testcases/kernel/syscalls/write/write05.c
index c1e48f1df..1e85cce6d 100644
--- a/testcases/kernel/syscalls/write/write05.c
+++ b/testcases/kernel/syscalls/write/write05.c
@@ -59,26 +59,12 @@ static void verify_write(unsigned int i)
 
 	sigpipe_cnt = 0;
 
-	TEST(write(*tc->fd, *tc->buf, tc->size));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "write() succeeded unexpectedly");
-		return;
-	}
-
-	if (TST_ERR != tc->exp_errno) {
-		tst_res(TFAIL | TTERRNO,
-			"write() failed unexpectedly, expected %s",
-			tst_strerrno(tc->exp_errno));
+	TST_EXP_FAIL(write(*tc->fd, *tc->buf, tc->size), tc->exp_errno);
+	if (TST_RET != -1)
 		return;
-	}
 
-	if (tc->exp_errno == EPIPE && sigpipe_cnt != 1) {
+	if (tc->exp_errno == EPIPE && sigpipe_cnt != 1)
 		tst_res(TFAIL, "sigpipe_cnt = %i", sigpipe_cnt);
-		return;
-	}
-
-	tst_res(TPASS | TTERRNO, "write() failed expectedly");
 }
 
 static void setup(void)
-- 
2.40.1


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 1/1] write05: Simplify test using TST_ macros
  2023-07-21 10:03 [LTP] [PATCH 1/1] write05: Simplify test using TST_ macros Petr Vorel
@ 2023-07-21 12:29 ` Avinesh Kumar
  2023-07-21 14:31   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Avinesh Kumar @ 2023-07-21 12:29 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr,

On Friday, July 21, 2023 3:33:30 PM IST Petr Vorel wrote:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/syscalls/write/write05.c | 20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/write/write05.c
> b/testcases/kernel/syscalls/write/write05.c index c1e48f1df..1e85cce6d
> 100644
> --- a/testcases/kernel/syscalls/write/write05.c
> +++ b/testcases/kernel/syscalls/write/write05.c
> @@ -59,26 +59,12 @@ static void verify_write(unsigned int i)
> 
>  	sigpipe_cnt = 0;
> 
> -	TEST(write(*tc->fd, *tc->buf, tc->size));
> -
> -	if (TST_RET != -1) {
> -		tst_res(TFAIL, "write() succeeded unexpectedly");
> -		return;
> -	}
> -
> -	if (TST_ERR != tc->exp_errno) {
> -		tst_res(TFAIL | TTERRNO,
> -			"write() failed unexpectedly, expected %s",
> -			tst_strerrno(tc->exp_errno));
> +	TST_EXP_FAIL(write(*tc->fd, *tc->buf, tc->size), tc->exp_errno);
Should we use TST_EXP_FAIL2 instead?

Maybe we can also do the ascii doc changes and headers cleanup, but I'm fine if 
we do that in a separate patch.

Reviewed-by: Avinesh Kumar <akumar@suse.de>


Regards,
Avinesh




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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH 1/1] write05: Simplify test using TST_ macros
  2023-07-21 12:29 ` Avinesh Kumar
@ 2023-07-21 14:31   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2023-07-21 14:31 UTC (permalink / raw)
  To: Avinesh Kumar; +Cc: ltp

> Hi Petr,

> On Friday, July 21, 2023 3:33:30 PM IST Petr Vorel wrote:
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  testcases/kernel/syscalls/write/write05.c | 20 +++-----------------
> >  1 file changed, 3 insertions(+), 17 deletions(-)

> > diff --git a/testcases/kernel/syscalls/write/write05.c
> > b/testcases/kernel/syscalls/write/write05.c index c1e48f1df..1e85cce6d
> > 100644
> > --- a/testcases/kernel/syscalls/write/write05.c
> > +++ b/testcases/kernel/syscalls/write/write05.c
> > @@ -59,26 +59,12 @@ static void verify_write(unsigned int i)

> >  	sigpipe_cnt = 0;

> > -	TEST(write(*tc->fd, *tc->buf, tc->size));
> > -
> > -	if (TST_RET != -1) {
> > -		tst_res(TFAIL, "write() succeeded unexpectedly");
> > -		return;
> > -	}
> > -
> > -	if (TST_ERR != tc->exp_errno) {
> > -		tst_res(TFAIL | TTERRNO,
> > -			"write() failed unexpectedly, expected %s",
> > -			tst_strerrno(tc->exp_errno));
> > +	TST_EXP_FAIL(write(*tc->fd, *tc->buf, tc->size), tc->exp_errno);
> Should we use TST_EXP_FAIL2 instead?

Good catch, write() requires TST_EXP_FAIL2(). Thanks!
Merged with this fix.

> Maybe we can also do the ascii doc changes and headers cleanup, but I'm fine if 
> we do that in a separate patch.

I dared to merge this before without a review as it's simple (bad habit).
Generally, the best approach (which I not always follow) is to separate changes.
That's why I usually add docparse change as a separate commit. But I usually
update copyright with other changes (that's really minor change).

> Reviewed-by: Avinesh Kumar <akumar@suse.de>


Kind regards,
Petr


> Regards,
> Avinesh




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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-21 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 10:03 [LTP] [PATCH 1/1] write05: Simplify test using TST_ macros Petr Vorel
2023-07-21 12:29 ` Avinesh Kumar
2023-07-21 14:31   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox