[Intel-gfx] [PATCH i-g-t 3/4] gem_create: Tidy object creation tests
Tvrtko Ursulin
tursulin at ursulin.net
Thu Mar 30 16:58:08 UTC 2017
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Copnsolidate and simplify tests that small objects are rounded
up to PAGE_SIZE and no more.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
tests/gem_create.c | 43 ++++++++++---------------------------------
1 file changed, 10 insertions(+), 33 deletions(-)
diff --git a/tests/gem_create.c b/tests/gem_create.c
index f687b7b40be4..21df13f7b655 100644
--- a/tests/gem_create.c
+++ b/tests/gem_create.c
@@ -106,41 +106,21 @@ static void invalid_size_test(int fd)
}
/*
- * Creating an object with non-aligned size and trying to access it with an
- * offset, which is greater than the requested size but smaller than the
- * object's last page boundary. pwrite here must be successful.
+ * Verify that the kernel rounds up object creation to PAGE_SIZE and no more.
*/
-static void valid_nonaligned_size(int fd)
+static void test_size_alignment(int fd)
{
- int handle;
- char buf[PAGE_SIZE];
-
- handle = gem_create(fd, PAGE_SIZE / 2);
-
- gem_write(fd, handle, PAGE_SIZE / 2, buf, PAGE_SIZE / 2);
-
- gem_close(fd, handle);
-}
-
-/*
- * Creating an object with non-aligned size and trying to access it with an
- * offset, which is greater than the requested size and larger than the
- * object's last page boundary. pwrite here must fail.
- */
-static void invalid_nonaligned_size(int fd)
-{
- int handle;
- char buf[PAGE_SIZE];
- struct drm_i915_gem_pwrite gem_pwrite;
+ uint32_t handle;
+ char buf[PAGE_SIZE + 1];
+ struct drm_i915_gem_pwrite gem_pwrite = { };
handle = gem_create(fd, PAGE_SIZE / 2);
+ gem_write(fd, handle, 0, buf, PAGE_SIZE);
- CLEAR(gem_pwrite);
gem_pwrite.handle = handle;
- gem_pwrite.offset = PAGE_SIZE / 2;
- gem_pwrite.size = PAGE_SIZE;
+ gem_pwrite.offset = 0;
+ gem_pwrite.size = PAGE_SIZE + 1;
gem_pwrite.data_ptr = to_user_pointer(buf);
- /* This should fail. Hence cannot use gem_write. */
igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite));
gem_close(fd, handle);
@@ -160,9 +140,6 @@ igt_main
igt_subtest("basic-create-invalid-size")
invalid_size_test(fd);
- igt_subtest("create-valid-nonaligned")
- valid_nonaligned_size(fd);
-
- igt_subtest("create-invalid-nonaligned")
- invalid_nonaligned_size(fd);
+ igt_subtest("basic-size-alignment")
+ test_size_alignment(fd);
}
--
2.9.3
More information about the Intel-gfx
mailing list