[PATCH] tests: Add test for decoding of PTP_* ioctl commands
Dmitry V. Levin
ldv at altlinux.org
Mon Feb 26 11:28:22 UTC 2018
On Mon, Feb 26, 2018 at 04:46:33PM +0530, Harsha Sharma wrote:
[...]
> >> +#include "xlat/ptp_flags_options.h"
> >> +
> >> +static void
> >> +test_no_device(void)
> >> +{
> >> + ioctl(-1, PTP_CLOCK_GETCAPS, NULL);
> >> + printf("ioctl(-1, PTP_CLOCK_GETCAPS, NULL) = -1 EBADF (%m)\n");
> >
> > You can also check decoding of non-zero arguments here.
>
> Should I add or replace with decoding of non-zero arguments here ?
> Other tests check for both.
You can add a check.
[...]
> >> + int getcaps_fd = ioctl(fd, PTP_CLOCK_GETCAPS, &caps);
> >> + printf("ioctl(%d, PTP_CLOCK_GETCAPS, %p) = %s\n",
> >> + fd, &caps, sprintrc(getcaps_fd));
> >
> > I don't think PTP_CLOCK_GETCAPS returns a file descriptor, so the name
> > getcaps_fd is confusing.
> >
> > It's definitely not a good idea to specify "struct ptp_clock_caps **"
> > argument to PTP_CLOCK_GETCAPS.
> >
> > When testing decoders of structures, we often place the structure
> > at the end of mapped memory region to test that strace does not attempt
> > to fetch memory beyond the end of structure, e.g.
> >
> > TAIL_ALLOC_OBJECT_CONST_PTR(struct ptp_clock_caps, caps);
>
> Using this results, into mismatch of strace decoding and printf output
> and test fails.
What kind of mismatch?
Note that caps is a pointer already, you have to specify "caps" in ioctl
and printf invocations, not "&caps".
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180226/f0172498/attachment.bin>
More information about the Strace-devel
mailing list