summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-07-25 12:54:15 -0700
committerEric Anholt <eric@anholt.net>2007-07-25 12:59:43 -0700
commitf2528cbc965858c6a7a81d659f9d5f4da290b5ae (patch)
treeabe963a4d1dc5ee24d4ecde7af4869df573b0645 /tests
parentbe3099f26547f48066bbdd7a36578b54da9170b4 (diff)
Improve the drawable test to use multiple drawables.
Diffstat (limited to 'tests')
-rw-r--r--tests/updatedraw.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/tests/updatedraw.c b/tests/updatedraw.c
index 1186783a..2f22fef2 100644
--- a/tests/updatedraw.c
+++ b/tests/updatedraw.c
@@ -83,16 +83,10 @@ set_draw_cliprects_2(int fd, int drawable)
assert(ret == 0);
}
-/**
- * Tests drawable management: adding, removing, and updating the cliprects of
- * drawables.
- */
-int main(int argc, char **argv)
+static int add_drawable(int fd)
{
drm_draw_t drawarg;
- int fd, ret, drawable;
-
- fd = drm_open_any_master();
+ int ret;
/* Create a drawable.
* IOCTL_ADD_DRAW is RDWR, though it should really just be RD
@@ -100,27 +94,54 @@ int main(int argc, char **argv)
drawarg.handle = 0;
ret = ioctl(fd, DRM_IOCTL_ADD_DRAW, &drawarg);
assert(ret == 0);
- drawable = drawarg.handle;
+ return drawarg.handle;
+}
- /* Do a series of cliprect updates */
- set_draw_cliprects_empty(fd, drawable);
- set_draw_cliprects_2(fd, drawable);
- set_draw_cliprects_empty(fd, drawable);
+static int rm_drawable(int fd, int drawable, int fail)
+{
+ drm_draw_t drawarg;
+ int ret;
- /* Remove our drawable */
+ /* Create a drawable.
+ * IOCTL_ADD_DRAW is RDWR, though it should really just be RD
+ */
drawarg.handle = drawable;
ret = ioctl(fd, DRM_IOCTL_RM_DRAW, &drawarg);
- assert(ret == 0);
- drawable = drawarg.handle;
+ if (!fail)
+ assert(ret == 0);
+ else
+ assert(ret == -1 && errno == EINVAL);
+
+ return drawarg.handle;
+}
+
+/**
+ * Tests drawable management: adding, removing, and updating the cliprects of
+ * drawables.
+ */
+int main(int argc, char **argv)
+{
+ int fd, ret, d1, d2;
+
+ fd = drm_open_any_master();
+
+ d1 = add_drawable(fd);
+ d2 = add_drawable(fd);
+ /* Do a series of cliprect updates */
+ set_draw_cliprects_empty(fd, d1);
+ set_draw_cliprects_empty(fd, d2);
+ set_draw_cliprects_2(fd, d1);
+ set_draw_cliprects_empty(fd, d1);
+
+ /* Remove our drawables */
+ rm_drawable(fd, d1, 0);
+ rm_drawable(fd, d2, 0);
/* Check that removing an unknown drawable returns error */
- drawarg.handle = 0x7fffffff;
- ret = ioctl(fd, DRM_IOCTL_RM_DRAW, &drawarg);
- assert(ret == -1 && errno == EINVAL);
- drawable = drawarg.handle;
+ rm_drawable(fd, 0x7fffffff, 1);
/* Attempt to set cliprects on a nonexistent drawable */
- set_draw_cliprects_empty_fail(fd, drawable);
+ set_draw_cliprects_empty_fail(fd, d1);
close(fd);
return 0;