From 8e46c382e359c7a3d465bb1505e7f8b63a7a5952 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 23 Jul 2013 22:43:30 +0200 Subject: [PATCH] lib/drmtest: add gem_flink and gem_open Requires us to rename a few things in the gem_flink test to avoid variable shadowing. Signed-off-by: Daniel Vetter --- lib/drmtest.c | 25 +++++++++++++++++++++++++ lib/drmtest.h | 2 ++ tests/gem_flink.c | 28 ++++++++++++++-------------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index a18e61f..083191d 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -432,6 +432,31 @@ int gem_get_cacheing(int fd, uint32_t handle) return arg.cacheing; } +uint32_t gem_open(int fd, uint32_t name) +{ + struct drm_gem_open open_struct; + int ret; + + open_struct.name = name; + ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &open_struct); + assert(ret == 0); + assert(open_struct.handle != 0); + + return open_struct.handle; +} + +uint32_t gem_flink(int fd, uint32_t handle) +{ + struct drm_gem_flink flink; + int ret; + + flink.handle = handle; + ret = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); + assert(ret == 0); + + return flink.name; +} + void gem_close(int fd, uint32_t handle) { struct drm_gem_close close_bo; diff --git a/lib/drmtest.h b/lib/drmtest.h index 5961d73..6db639f 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -56,6 +56,8 @@ int gem_get_num_rings(int fd); int gem_has_cacheing(int fd); void gem_set_cacheing(int fd, uint32_t handle, int cacheing); int gem_get_cacheing(int fd, uint32_t handle); +uint32_t gem_flink(int fd, uint32_t handle); +uint32_t gem_open(int fd, uint32_t name); void gem_close(int fd, uint32_t handle); void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size); void gem_read(int fd, uint32_t handle, uint32_t offset, void *buf, uint32_t size); diff --git a/tests/gem_flink.c b/tests/gem_flink.c index bfa85c9..cc4f0e5 100644 --- a/tests/gem_flink.c +++ b/tests/gem_flink.c @@ -43,7 +43,7 @@ test_flink(int fd) { struct drm_i915_gem_create create; struct drm_gem_flink flink; - struct drm_gem_open gem_open; + struct drm_gem_open open_struct; int ret; printf("Testing flink and open.\n"); @@ -57,10 +57,10 @@ test_flink(int fd) ret = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); assert(ret == 0); - gem_open.name = flink.name; - ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &gem_open); + open_struct.name = flink.name; + ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &open_struct); assert(ret == 0); - assert(gem_open.handle != 0); + assert(open_struct.handle != 0); } static void @@ -104,13 +104,13 @@ test_bad_flink(int fd) static void test_bad_open(int fd) { - struct drm_gem_open gem_open; + struct drm_gem_open open_struct; int ret; printf("Testing error return on bad open ioctl.\n"); - gem_open.name = 0x10101010; - ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &gem_open); + open_struct.name = 0x10101010; + ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &open_struct); assert(ret == -1 && errno == ENOENT); } @@ -120,7 +120,7 @@ test_flink_lifetime(int fd) { struct drm_i915_gem_create create; struct drm_gem_flink flink; - struct drm_gem_open gem_open; + struct drm_gem_open open_struct; int ret, fd2; printf("Testing flink lifetime.\n"); @@ -136,18 +136,18 @@ test_flink_lifetime(int fd) ret = ioctl(fd2, DRM_IOCTL_GEM_FLINK, &flink); assert(ret == 0); - gem_open.name = flink.name; - ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &gem_open); + open_struct.name = flink.name; + ret = ioctl(fd, DRM_IOCTL_GEM_OPEN, &open_struct); assert(ret == 0); - assert(gem_open.handle != 0); + assert(open_struct.handle != 0); close(fd2); fd2 = drm_open_any(); - gem_open.name = flink.name; - ret = ioctl(fd2, DRM_IOCTL_GEM_OPEN, &gem_open); + open_struct.name = flink.name; + ret = ioctl(fd2, DRM_IOCTL_GEM_OPEN, &open_struct); assert(ret == 0); - assert(gem_open.handle != 0); + assert(open_struct.handle != 0); } int main(int argc, char **argv) -- 2.7.4