public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] splice02: Generate input in C
Date: Thu, 15 Apr 2021 16:11:03 +0200	[thread overview]
Message-ID: <YHhJdwbeUCz5sDfK@pevik> (raw)
In-Reply-To: <YHhDurTlljhXAKL9@yuki>

Hi Cyril,

> I meant that we could simplify the test with:

> diff --git a/testcases/kernel/syscalls/splice/splice02.c b/testcases/kernel/syscalls/splice/splice02.c
> index fd71f2995..1b566a2f4 100644
> --- a/testcases/kernel/syscalls/splice/splice02.c
> +++ b/testcases/kernel/syscalls/splice/splice02.c
> @@ -54,18 +54,13 @@ static void do_child(void)

>  	fd = SAFE_OPEN(TEST_FILENAME, O_WRONLY | O_CREAT | O_TRUNC, 0644);

> -	while (to_write > 0) {
> +	do {
>  		TEST(splice(STDIN_FILENO, NULL, fd, NULL, WRITE_SIZE, 0));
> -		tst_res(TINFO, "splice() wrote %ld, remaining %d", TST_RET, to_write);
>  		if (TST_RET < 0) {
>  			tst_res(TFAIL | TTERRNO, "splice failed");
>  			goto cleanup;
> -		} else if (!TST_RET) {
> -			break;
> -		} else {
> -			to_write -= TST_RET;
>  		}
> -	}
> +	} while (TST_RET > 0);

>  	stat(TEST_FILENAME, &st);
>  	if (st.st_size != num_writes) {
> @@ -100,10 +95,10 @@ static void run(void)
>  	for (i = 0; i < num_writes; i++)
>  		SAFE_WRITE(1, pipe_fd[1], "x", 1);

> -	tst_reap_children();
> -
>  	SAFE_CLOSE(pipe_fd[0]);
>  	SAFE_CLOSE(pipe_fd[1]);
> +
> +	tst_reap_children();
>  }

>  static struct tst_test test = {


> If you close the pipe in the parent before reaping children the last
> splice() will return 0 and exit the loop. No need to count anything.

LGTM, going to merge it with these changes (+ cleanup to_write)
and your Reviewed-by: tags.
Thanks a lot!

Kind regards,
Petr

  reply	other threads:[~2021-04-15 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  4:38 [LTP] [PATCH v3 1/2] splice02: Generate input in C Petr Vorel
2021-04-13  4:38 ` [LTP] [PATCH v3 2/2] commands: Add shell pipe test Petr Vorel
2021-04-15 13:46 ` [LTP] [PATCH v3 1/2] splice02: Generate input in C Cyril Hrubis
2021-04-15 14:11   ` Petr Vorel [this message]
2021-04-15 14:27     ` Petr Vorel
2021-04-16 12:32       ` Cyril Hrubis
2021-04-16 13:10         ` Petr Vorel

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=YHhJdwbeUCz5sDfK@pevik \
    --to=pvorel@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