Skip to contentSkip to conversation

tests/gem_wait_render_timeout: Drop local structs

PATCH New Daniel Vetter 1 participant 3 messages Sep 29, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tests/gem_wait_render_timeout: Drop local structs

We're long past the point where libdrm has these.

---
 tests/gem_wait_render_timeout.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
tests/gem_wait_render_timeout.c +2 -13
index e05b7ae203a5..86640faf442a 100644
@@ -69,21 +69,10 @@ do_time_diff(struct timespec *end, struct timespec *start)
 	return ret;
 }
 
-/* to avoid stupid depencies on libdrm, copy&paste */
-struct local_drm_i915_gem_wait {
-	/** Handle of BO we shall wait on */
-	__u32 bo_handle;
-	__u32 flags;
-	/** Number of nanoseconds to wait, Returns time remaining. */
-	__u64 timeout_ns;
-};
-
-# define WAIT_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2c, struct local_drm_i915_gem_wait)
-
 static int
 gem_bo_wait_timeout(int fd, uint32_t handle, uint64_t *timeout_ns)
 {
-	struct local_drm_i915_gem_wait wait;
+	struct drm_i915_gem_wait wait;
 	int ret;
 
 	igt_assert(timeout_ns);
@@ -91,7 +80,7 @@ gem_bo_wait_timeout(int fd, uint32_t handle, uint64_t *timeout_ns)
 	wait.bo_handle = handle;
 	wait.timeout_ns = *timeout_ns;
 	wait.flags = 0;
-	ret = drmIoctl(fd, WAIT_IOCTL, &wait);
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
 	*timeout_ns = wait.timeout_ns;
 
 	return ret ? -errno : 0;
Signature · 1 line
1.9.3
#1 lore raw

PATCH 2/3 tests/gem_wait_render_timeout: Convert to subtests

I want to add a bunch of api tests besides the functional "render-timeout" testcase.

---
 tests/.gitignore                |   2 +-
 tests/Makefile.sources          |   2 +-
 tests/gem_wait.c                | 232 ++++++++++++++++++++++++++++++++++++++++
 tests/gem_wait_render_timeout.c | 219 -------------------------------------
 4 files changed, 234 insertions(+), 221 deletions(-)
 create mode 100644 tests/gem_wait.c
 delete mode 100644 tests/gem_wait_render_timeout.c
tests/.gitignore +1 -1
index c6a99bed926b..bb90685ba3cc 100644
@@ -104,7 +104,7 @@ gem_tiling_max_stride
 gem_unfence_active_buffers
 gem_unref_active_buffers
 gem_userptr_blits
-gem_wait_render_timeout
+gem_wait
 gem_write_read_ring_switch
 gem_workarounds
 gen3_mixed_blits
tests/Makefile.sources +1 -1
index d18d7b5818ff..5202ab2642c2 100644
@@ -136,7 +136,7 @@ TESTS_progs = \
 	gem_tiling_max_stride \
 	gem_unfence_active_buffers \
 	gem_unref_active_buffers \
-	gem_wait_render_timeout \
+	gem_wait \
 	gem_workarounds \
 	gen3_mixed_blits \
 	gen3_render_linear_blits \
tests/gem_wait.c new file +232 -0

232 lines not on this page · raw message

tests/gem_wait_render_timeout.c deleted +0 -219

219 lines not on this page · raw message

Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/3 tests/gem_wait: argument validation tests

In reply to Daniel Vetter

Shockingly we don't check for 0 flags!

---
 tests/gem_wait.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
tests/gem_wait.c +36 -0
index 0a8ccf62150d..83ddb97216ab 100644
@@ -216,6 +216,37 @@ static void render_timeout(int fd)
 	close(fd);
 }
 
+static void invalid_flags(int fd)
+{
+	struct drm_i915_gem_wait wait;
+	int ret;
+	uint32_t handle;
+
+	handle = gem_create(fd, 4096);
+
+	wait.bo_handle = handle;
+	wait.timeout_ns = 1;
+	wait.flags = 0xffffffff;
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+
+	igt_assert(ret != 0 && errno == EINVAL);
+
+	gem_close(fd, handle);
+}
+
+static void invalid_buf(int fd)
+{
+	struct drm_i915_gem_wait wait;
+	int ret;
+
+	wait.bo_handle = 0;
+	wait.timeout_ns = 1;
+	wait.flags = 0;
+	ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+
+	igt_assert(ret != 0 && errno == ENOENT);
+}
+
 int drm_fd;
 
 igt_main
@@ -226,6 +257,11 @@ igt_main
 	igt_subtest("render_timeout")
 		render_timeout(drm_fd);
 
+	igt_subtest("invalid-flags")
+		invalid_flags(drm_fd);
+
+	igt_subtest("invalid-buf")
+		invalid_buf(drm_fd);
 
 	igt_fixture
 		close(drm_fd);
Signature · 1 line
1.9.3