Re: [LTP] [PATCH 1/2] syscalls: Add test for splicing from /dev/zero and /dev/full

Petr Vorel
2024-03-21T09:29:46Z

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