summaryrefslogtreecommitdiff
path: root/tests/prime_mmap.c
diff options
context:
space:
mode:
authorNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>2022-07-01 16:05:44 -0700
committerAndi Shyti <andi.shyti@linux.intel.com>2022-07-09 02:43:54 +0200
commitd33d1f0df600f6b8a868daa23832749e26b09b55 (patch)
tree1e3226f2b5d68d27834bed54a4d3fd862fc70cc8 /tests/prime_mmap.c
parent790c1b18ca0815ca14b320e3b4d9e262fe46f1a4 (diff)
tests/i915/vm_bind: Add vm_bind sanity test
Add sanity test to exercise vm_bind uapi. Test for various cases with vm_bind and vm_unbind ioctls. Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Diffstat (limited to 'tests/prime_mmap.c')
-rw-r--r--tests/prime_mmap.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index d53185ff..4c765649 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -298,24 +298,6 @@ test_dup(uint32_t region, int size)
close (dma_buf_fd);
}
-/* Used for error case testing to avoid wrapper */
-static int prime_handle_to_fd_no_assert(uint32_t handle, int flags, int *fd_out)
-{
- struct drm_prime_handle args;
- int ret;
-
- args.handle = handle;
- args.flags = flags;
- args.fd = -1;
-
- ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
- if (ret)
- ret = errno;
- *fd_out = args.fd;
-
- return ret;
-}
-
static bool has_userptr(void)
{
uint32_t handle = 0;
@@ -346,9 +328,9 @@ test_userptr(uint32_t region, int size)
gem_userptr(fd, (uint32_t *)ptr, size, 0, 0, &handle);
/* export userptr */
- ret = prime_handle_to_fd_no_assert(handle, DRM_CLOEXEC, &dma_buf_fd);
+ ret = prime_handle_to_fd_no_assert(fd, handle, DRM_CLOEXEC, &dma_buf_fd);
if (ret) {
- igt_assert(ret == EINVAL || ret == ENODEV);
+ igt_assert(ret == -EINVAL || ret == -ENODEV);
goto free_userptr;
} else {
igt_assert_eq(ret, 0);
@@ -376,7 +358,7 @@ test_errors(uint32_t region, int size)
/* Test for invalid flags */
handle = gem_create_in_memory_regions(fd, size, region);
for (i = 0; i < ARRAY_SIZE(invalid_flags); i++) {
- prime_handle_to_fd_no_assert(handle, invalid_flags[i], &dma_buf_fd);
+ prime_handle_to_fd_no_assert(fd, handle, invalid_flags[i], &dma_buf_fd);
igt_assert_eq(errno, EINVAL);
errno = 0;
}
@@ -386,7 +368,7 @@ test_errors(uint32_t region, int size)
handle = gem_create_in_memory_regions(fd, size, region);
fill_bo(handle, size);
gem_close(fd, handle);
- prime_handle_to_fd_no_assert(handle, DRM_CLOEXEC, &dma_buf_fd);
+ prime_handle_to_fd_no_assert(fd, handle, DRM_CLOEXEC, &dma_buf_fd);
igt_assert(dma_buf_fd == -1 && errno == ENOENT);
errno = 0;