[PATCH v2] tests: Add test for decoding of PTP_* ioctl commands

Harsha Sharma harshasharmaiitr at gmail.com
Tue Feb 27 11:08:52 UTC 2018


On Mon, Feb 26, 2018 at 7:47 PM, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Mon, Feb 26, 2018 at 06:20:22PM +0530, Harsha Sharma wrote:
> [...]
>> +#include "tests.h"
>> +#include "xlat.h"
>> +#include <fcntl.h>
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <sys/ioctl.h>
>> +#include <inttypes.h>
>> +#include <unistd.h>
>> +
>> +#ifdef HAVE_STRUCT_PTP_SYS_OFFSET
>
> I don't think this is going to build if the macro is not defined.
> See many examples e.g. tests/ioctl_mtd.c how to do it properly.
>
> [...]
>> +     /* PTP_PEROUT_REQUEST */
>> +     ioctl(-1, PTP_PEROUT_REQUEST, NULL);
>> +     printf("ioctl(-1, PTP_PEROUT_REQUEST, NULL) = -1 EBADF (%m)\n");
>> +     ioctl(-1, PTP_PEROUT_REQUEST, perout);
>> +     printf("ioctl(-1, PTP_PEROUT_REQUEST, {start={%" PRId64 ""
>> +            ", %" PRIu32 "}, period={%" PRId64 ", %" PRIu32 "}"
>> +            ", index=%d, flags=", (int64_t)perout->start.sec,
>> +            perout->start.nsec, (int64_t)perout->period.sec,
>> +            perout->period.nsec, perout->index);
>
> From this expected output I can tell that the decoder itself
> should be fixed to print field names along with their values.

Do you mean, printing it in this way: {start={sec=%" PRId64 ", nsec=%"
PRIu32 "}, period={sec=%" PRId64 ",  nsec=%" PRIu32 "}", index=%d,
flags=" ?
If it is so, should I change it in same patch ?

> [...]
>> +     /* PTP_CLOCK_GETCAPS */
>> +     int getcaps_ret = ioctl(fd, PTP_CLOCK_GETCAPS, caps);
>> +     printf("ioctl(%d, PTP_CLOCK_GETCAPS, %p) = %s\n",
>> +            fd, caps,  sprintrc(getcaps_ret));
>
> What if PTP_CLOCK_GETCAPS actually succeeds?
>
>> +     /* PTP_SYS_OFFSET */
>> +     int sysoff_ret = ioctl(fd, PTP_SYS_OFFSET, sysoff);
>> +     printf("ioctl(%d, PTP_SYS_OFFSET, {n_samples=%u}) = %s\n",
>> +            fd, sysoff->n_samples, sprintrc(sysoff_ret));
>
> Likewise, what if you specified sysoff->n_samples <= PTP_MAX_SAMPLES
> and the call actually succeeded?

Should I take this case in test, beacuse other tests like ioctl_mtd
don't consider this case ?
Thanks for your time.

Regards,
Harsha Sharma

>
> --
> ldv
>
> --
> Strace-devel mailing list
> Strace-devel at lists.strace.io
> https://lists.strace.io/mailman/listinfo/strace-devel
>


More information about the Strace-devel mailing list