public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/2] syscalls: Add test for splicing from /dev/zero and /dev/full
Date: Thu, 21 Mar 2024 10:29:22 +0100	[thread overview]
Message-ID: <20240321092922.GA548078@pevik> (raw)
In-Reply-To: <20240320095927.19973-2-chrubis@suse.cz>

Hi Cyril,

> +static void test_splice(unsigned int bytes, int dev_fd)
> +{
> +	int pipefd[2];
> +	char buf[bytes];
> +	size_t i;
> +	int fail = 0;
> +
> +	memset(buf, 0xff, sizeof(buf));
> +
> +	SAFE_PIPE(pipefd);
> +
> +	TST_EXP_POSITIVE(splice(dev_fd, NULL, pipefd[1], NULL, sizeof(buf), 0));
> +
> +	if (!TST_PASS)
> +		goto ret;
> +
> +	SAFE_READ(1, pipefd[0], buf, sizeof(buf));
> +
> +	for (i = 0; i < sizeof(buf); i++) {
> +		if (buf[i])
> +			fail++;
> +	}
> +
> +	if (fail)
> +		tst_res(TFAIL, "Non-zero bytes spliced from /dev/zero");
Maybe write how many fail we have?

I also agree with Jan's comment about missing TST_RET, which is in splice09.

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

> +	else
> +		tst_res(TPASS, "All bytes spliced from /dev/zero are zeroed");
> +
> +ret:
> +	SAFE_CLOSE(pipefd[0]);
> +	SAFE_CLOSE(pipefd[1]);
> +}
> +
> +static void verify_splice(unsigned int n)
> +{
> +	unsigned int bytes = 1009 * n;

Out of curiosity, why 1009 and not 1000?

Kind regards,
Petr

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

  parent reply	other threads:[~2024-03-21  9:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  9:59 [LTP] [PATCH 0/2] Add splice tests fro /dev/{zero,null,full} Cyril Hrubis
2024-03-20  9:59 ` [LTP] [PATCH 1/2] syscalls: Add test for splicing from /dev/zero and /dev/full Cyril Hrubis
2024-03-20 13:26   ` Jan Stancek
2024-04-11 10:43     ` Cyril Hrubis
2024-04-11 11:08       ` Jan Stancek
2024-04-11 11:50         ` Cyril Hrubis
2024-03-21  9:29   ` Petr Vorel [this message]
2024-04-11 10:42     ` Cyril Hrubis
2024-03-20  9:59 ` [LTP] [PATCH 2/2] syscalls: Add test for splicing to /dev/zero and /dev/null Cyril Hrubis
2024-03-21  9:33   ` Petr Vorel
2024-04-11 10:36     ` 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=20240321092922.GA548078@pevik \
    --to=pvorel@suse.cz \
    --cc=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