From 9d8fc1957c8cccb6875264334cd67bb24c6e7c54 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 7 Jun 2013 11:44:40 +0100 Subject: [PATCH] gem_lut_handle: Avoid using a valid handle when testing BROKEN --- tests/gem_lut_handle.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/gem_lut_handle.c b/tests/gem_lut_handle.c index c31c5ffc..ebc68dfd 100644 --- a/tests/gem_lut_handle.c +++ b/tests/gem_lut_handle.c @@ -94,7 +94,7 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 *gem_exec; struct drm_i915_gem_relocation_entry *gem_reloc; - unsigned min_handle = 0, max_handle = ~0; + unsigned max_handle = batch; int ret, n; gem_exec = calloc(num_exec+1, sizeof(*gem_exec)); @@ -103,8 +103,6 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign for (n = 0; n < num_exec; n++) { gem_exec[n].handle = gem_create(fd, 4096); - if (gem_exec[n].handle < min_handle) - min_handle = gem_exec[n].handle; if (gem_exec[n].handle > max_handle) max_handle = gem_exec[n].handle; gem_exec[n].relocation_count = 0; @@ -120,18 +118,17 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign gem_exec[n].relocation_count = num_reloc; gem_exec[n].relocs_ptr = (uintptr_t) gem_reloc; - if (flags & USE_LUT) { - min_handle = 0; + if (flags & USE_LUT) max_handle = num_exec + 1; - } + max_handle++; for (n = 0; n < num_reloc; n++) { unsigned target; if (flags & BROKEN) { target = rand(); - if (target <= max_handle && target >= min_handle) - target = target & 1 ? min_handle - target : max_handle + target; + if (target <= max_handle) + target = target & 1 ? -target : max_handle + target; } else { target = rand() % (num_exec + 1); if ((flags & USE_LUT) == 0)