[igt-dev] [Intel-gfx] [PATCH i-g-t v3 1/2] tests/gem_ctx_bad_exec: Consolidate to gem_ctx_exec

Chris Wilson chris at chris-wilson.co.uk
Tue Sep 18 11:06:41 UTC 2018


Quoting Tvrtko Ursulin (2018-09-18 11:59:25)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Move a really small test that invalid context is rejected under the
> gem_ctx_exec umbrella.
> 
> v2:
>  * And actually fix the test so it does what it claims. And add more
>    variety in the invalid context id's it tests with. (Chris Wilson)
> 
> v3:
>  * Rename the test as basic.
>  * Limit to 32-bit. (Chris Wilson)
>  * Add previously valid but closed context id to the test. (Chris Wilson)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> diff --git a/tests/gem_ctx_exec.c b/tests/gem_ctx_exec.c
> index 1f8ed64d4bd3..1c6c18eddc20 100644
> --- a/tests/gem_ctx_exec.c
> +++ b/tests/gem_ctx_exec.c
> @@ -30,6 +30,7 @@
>   */
>  
>  #include "igt.h"
> +#include <limits.h>
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <stdint.h>
> @@ -142,6 +143,34 @@ static void big_exec(int fd, uint32_t handle, int ring)
>         gem_sync(fd, handle);
>  }
>  
> +static void invalid_context(int fd, unsigned ring, uint32_t handle)
> +{
> +       struct drm_i915_gem_exec_object2 obj = {
> +               .handle = handle,
> +       };
> +       struct drm_i915_gem_execbuffer2 execbuf = {
> +               .buffers_ptr = to_user_pointer(&obj),
> +               .buffer_count = 1,
> +               .flags = ring,
> +       };
> +       uint32_t invalid[] = { 0, 1, INT_MAX, UINT_MAX };

I think I would also do
i915_execbuffer2_set_context_id(execbuf, 0);
igt_assert_eq(__gem_execbuf(fd, &execbuf), 0);
for (int bit = 0; bit < 31; bit++) {
	i915_execbuffer2_set_context_id(execbuf, 1ul << bit);
	igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT);
}
as that would catch any aliasing <32bits with pot mask. (I leave
detection of N % M to fuzzers!)

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list