[PATCH] tests: enhance printstr decode check

JingPiao Chen chenjingpiao at gmail.com
Wed Jun 14 11:09:26 UTC 2017


On Wed, Jun 14, 2017 at 01:39:47PM +0300, Dmitry V. Levin wrote:
> On Wed, Jun 14, 2017 at 11:54:16AM +0800, JingPiao Chen wrote:
> > * tests/printstr.c: Add a case for room < DEFAULT_STRLEN + 1.
>
> According to the coverage statistics, this branch of code is already
> tested, but one more explicit test won't harm anyway.

I write this case because it make me understand printstr behavior clearer.
I did not know that before. Maybe help other understand it.

>
> > ---
> >  tests/printstr.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/tests/printstr.c b/tests/printstr.c
> > index 330234f..035ce9c 100644
> > --- a/tests/printstr.c
> > +++ b/tests/printstr.c
> > @@ -40,7 +40,7 @@ int
> >  main(void)
> >  {
> >   char *const buf = tail_alloc(DEFAULT_STRLEN + 1);
> > - const struct iovec io = {
> > + struct iovec io = {
> >   .iov_base = buf,
> >   .iov_len = -1
> >   };
> > @@ -64,6 +64,11 @@ main(void)
> >   tprintf("writev(-1, [{iov_base=\"\\0%*s\"..., iov_len=%lu}], 1)"
> >   " = %s\n", DEFAULT_STRLEN - 1, buf + 1, -1UL, sprintrc(rc));
> >
> > + io.iov_base += 1;
>
> I'd change this to ++io.iov_base;
>
> > + rc = writev(-1, &io, 1);
> > + tprintf("writev(-1, [{iov_base=%p, iov_len=%lu}], 1)"
> > + " = %s\n", io.iov_base, -1UL, sprintrc(rc));
>
> I wouldn't split the first argument because it fits the line.
>
> > +
> >   tprintf("+++ exited with 0 +++\n");
> >   return 0;
> >  }
>
> No need to post v2, just keep in mind.

Thank you.

--
JingPiao Chen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170614/fcf89a1d/attachment.html>


More information about the Strace-devel mailing list