anv: gem-stubs: return a valid fd got anv_gem_userptr()
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 25 Sep 2019 13:26:52 +0000 (16:26 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 25 Sep 2019 19:02:51 +0000 (22:02 +0300)
Fixes invalid close(-1) in the unit tests.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_gem_stubs.c

index 2c27ce26f37813d3d0735486b2094fdee0cdb6b7..bc9d7e066ba93ea5837e03ed7e32ff11b4e47fe3 100644 (file)
@@ -68,7 +68,13 @@ anv_gem_munmap(void *p, uint64_t size)
 uint32_t
 anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
 {
-   return -1;
+   int fd = os_create_anonymous_file(size, "fake bo");
+   if (fd == -1)
+      return 0;
+
+   assert(fd != 0);
+
+   return fd;
 }
 
 int