summaryrefslogtreecommitdiff
path: root/tests/prime_mmap.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-04-12 19:07:17 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-04-17 14:07:53 +0100
commit83ba5b7d3bde48b383df41792fc9c955a5a23bdb (patch)
tree8fc8f2a4d3c9236d17162cdbabc1cf07f964f54b /tests/prime_mmap.c
parentddbe5a4d8bb1780ecf07f72e815062d3bce8ff71 (diff)
igt/prime_mmap: Test for userptr support first
Before we start trying to use userptr to test interoperability with PRIME, we first need to check that the device in question has userptr support. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106013 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests/prime_mmap.c')
-rw-r--r--tests/prime_mmap.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index 0da0aa68..67a6a232 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -307,6 +307,19 @@ static int prime_handle_to_fd_no_assert(uint32_t handle, int flags, int *fd_out)
return ret;
}
+static bool has_userptr(void)
+{
+ uint32_t handle = 0;
+ void *ptr;
+
+ igt_assert(posix_memalign(&ptr, 4096, 4096) == 0);
+ if ( __gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0)
+ gem_close(fd, handle);
+ free(ptr);
+
+ return handle;
+}
+
/* test for mmap(dma_buf_export(userptr)) */
static void
test_userptr(void)
@@ -315,6 +328,8 @@ test_userptr(void)
void *ptr;
uint32_t handle;
+ igt_require(has_userptr());
+
/* create userptr bo */
ret = posix_memalign(&ptr, 4096, BO_SIZE);
igt_assert_eq(ret, 0);