summaryrefslogtreecommitdiff
path: root/tests/gem_reloc_overflow.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-19 10:20:46 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-19 10:20:46 +0200
commitbf6f166035bdd85042c2d6dee0e0b088e122ae81 (patch)
tree369640ce1b87962c192b9a68b48a7b9801581fd6 /tests/gem_reloc_overflow.c
parent0a587e24b77707099a21d6ad00cbfd19a4661b8b (diff)
tests/gem_reloc_overflow: Extract reloc_tests
I'll be adding more stuff soon ;-) Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_reloc_overflow.c')
-rw-r--r--tests/gem_reloc_overflow.c98
1 files changed, 50 insertions, 48 deletions
diff --git a/tests/gem_reloc_overflow.c b/tests/gem_reloc_overflow.c
index 3d102bcc..0ff345f5 100644
--- a/tests/gem_reloc_overflow.c
+++ b/tests/gem_reloc_overflow.c
@@ -153,55 +153,10 @@ static void source_offset_tests(void)
gem_close(fd, handle);
}
-int main(int argc, char *argv[])
+static void reloc_tests(void)
{
int i;
- size_t total_actual = 0;
unsigned int total_unsigned = 0;
- int total_signed = 0;
- igt_subtest_init(argc, argv);
-
- igt_fixture {
- int ring;
- uint32_t batch_data [2] = { MI_NOOP, MI_BATCH_BUFFER_END };
-
- fd = drm_open_any();
-
- /* Create giant reloc buffer area. */
- num = 257;
- entries = ((1ULL << 32) / (num - 1));
- reloc_size = entries * sizeof(struct drm_i915_gem_relocation_entry);
- reloc = mmap(NULL, reloc_size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON, -1, 0);
- igt_assert(reloc != MAP_FAILED);
-
- /* Allocate the handles we'll need to wrap. */
- handles = calloc(num, sizeof(*handles));
- for (i = 0; i < num; i++)
- handles[i] = gem_create(fd, 4096);
-
- if (intel_gen(intel_get_drm_devid(fd)) >= 6)
- ring = I915_EXEC_BLT;
- else
- ring = 0;
-
- /* Create relocation objects. */
- execobjs = calloc(num, sizeof(*execobjs));
- execbuf.buffers_ptr = (uintptr_t)execobjs;
- execbuf.batch_start_offset = 0;
- execbuf.batch_len = 8;
- execbuf.cliprects_ptr = 0;
- execbuf.num_cliprects = 0;
- execbuf.DR1 = 0;
- execbuf.DR4 = 0;
- execbuf.flags = ring;
- i915_execbuffer2_set_context_id(execbuf, 0);
- execbuf.rsvd2 = 0;
-
- batch_handle = gem_create(fd, 4096);
-
- gem_write(fd, batch_handle, 0, batch_data, sizeof(batch_data));
- }
igt_subtest("invalid-address") {
/* Attempt unmapped single entry. */
@@ -241,8 +196,6 @@ int main(int argc, char *argv[])
}
total_unsigned += obj->relocation_count;
- total_signed += obj->relocation_count;
- total_actual += obj->relocation_count;
}
execbuf.buffer_count = num;
@@ -250,6 +203,55 @@ int main(int argc, char *argv[])
ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
igt_assert(errno == EINVAL);
}
+}
+
+int main(int argc, char *argv[])
+{
+ igt_subtest_init(argc, argv);
+
+ igt_fixture {
+ int ring;
+ uint32_t batch_data [2] = { MI_NOOP, MI_BATCH_BUFFER_END };
+
+ fd = drm_open_any();
+
+ /* Create giant reloc buffer area. */
+ num = 257;
+ entries = ((1ULL << 32) / (num - 1));
+ reloc_size = entries * sizeof(struct drm_i915_gem_relocation_entry);
+ reloc = mmap(NULL, reloc_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+ igt_assert(reloc != MAP_FAILED);
+
+ /* Allocate the handles we'll need to wrap. */
+ handles = calloc(num, sizeof(*handles));
+ for (int i = 0; i < num; i++)
+ handles[i] = gem_create(fd, 4096);
+
+ if (intel_gen(intel_get_drm_devid(fd)) >= 6)
+ ring = I915_EXEC_BLT;
+ else
+ ring = 0;
+
+ /* Create relocation objects. */
+ execobjs = calloc(num, sizeof(*execobjs));
+ execbuf.buffers_ptr = (uintptr_t)execobjs;
+ execbuf.batch_start_offset = 0;
+ execbuf.batch_len = 8;
+ execbuf.cliprects_ptr = 0;
+ execbuf.num_cliprects = 0;
+ execbuf.DR1 = 0;
+ execbuf.DR4 = 0;
+ execbuf.flags = ring;
+ i915_execbuffer2_set_context_id(execbuf, 0);
+ execbuf.rsvd2 = 0;
+
+ batch_handle = gem_create(fd, 4096);
+
+ gem_write(fd, batch_handle, 0, batch_data, sizeof(batch_data));
+ }
+
+ reloc_tests();
source_offset_tests();