From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@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, 11 Apr 2024 12:42:14 +0200 [thread overview]
Message-ID: <Zhe-hlpYX2lDOd0U@yuki> (raw)
In-Reply-To: <20240321092922.GA548078@pevik>
Hi!
> > +{
> > + 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.
Will fix both.
> 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?
Because people tend to use buffers that are either power of two or
multiples of 100 or 1000. The 1009 is a prime number which means that
multiples of it will have "unexpected" sizes.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-04-11 10:43 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
2024-04-11 10:42 ` Cyril Hrubis [this message]
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=Zhe-hlpYX2lDOd0U@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.