[Intel-gfx] [PATCH i-g-t v2 01/13] lib/sw_sync: Add helper functions for managing synchronization primitives
Chris Wilson
chris at chris-wilson.co.uk
Wed Sep 14 12:18:08 UTC 2016
On Tue, Sep 13, 2016 at 11:40:18AM -0400, Robert Foss wrote:
>
>
> On 2016-09-13 07:03 AM, Chris Wilson wrote:
> >Try:
> >
> >int __sw_sync_fence_create(int fd, int32_t seqno) /* int32_t not unsigned ? */
> >{
> >
> > struct sw_sync_create_fence_data data;
> >
> > memset(&data, 0, sizeof(data));
> > data.value = seqno;
> >
> > if (igt_ioctl(fd, SW_SYNC_IOCT_CREATE_FENCE, &data))
> > return -errno;
> >
> > return data.fence;
> >}
> >
> >int sw_sync_fence_create(int fd, int32_t seqno)
> >{
> > int fence = __sw_sync_fence_create(fd, seqno);
> > igt_assert(fence >= 0);
> > return fence;
> >}
> >
> >Then only in the test code do you send garbage and check for the
> >expected errno.
> >
>
> What would the corresponding negative test code look like?
> A call to __sw_sync_fence_create? Then __sw_sync_fence_create would
> have to be made accessible outside of lib/sw_sync.
>
> Or maybe creating a second user of __sw_sync_fence_create along the
> lines of sw_sync_fence_create_fail with an inverted igt_assert check
> is what you're suggesting.
Exactly. Make the raw unchecked version available to tests. We have been
using __gem_foo() and gem_foo() to identify the difference. __gem_foo()
reports the error to the caller (so that they can feed in different
values of garbage and check for different errno, or maybe used as a
probe to see if the kernel supports such a function) and gem_foo() for
everyone else where we want to just focus on writing a test and hide the
error handling clutter.
Try not to put the error handling tests in the library itself.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list