2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
40 test_bad_close(int fd
)
42 struct drm_gem_close close
;
45 printf("Testing error return on bad close ioctl.\n");
47 close
.handle
= 0x10101010;
48 ret
= ioctl(fd
, DRM_IOCTL_GEM_CLOSE
, &close
);
50 assert(ret
== -1 && errno
== EINVAL
);
54 test_create_close(int fd
)
56 struct drm_i915_gem_create create
;
57 struct drm_gem_close close
;
60 printf("Testing creating and closing an object.\n");
62 memset(&create
, 0, sizeof(create
));
63 create
.size
= 16 * 1024;
64 ret
= ioctl(fd
, DRM_IOCTL_I915_GEM_CREATE
, &create
);
67 close
.handle
= create
.handle
;
68 ret
= ioctl(fd
, DRM_IOCTL_GEM_CLOSE
, &close
);
72 test_create_fd_close(int fd
)
74 struct drm_i915_gem_create create
;
77 printf("Testing closing with an object allocated.\n");
79 memset(&create
, 0, sizeof(create
));
80 create
.size
= 16 * 1024;
81 ret
= ioctl(fd
, DRM_IOCTL_I915_GEM_CREATE
, &create
);
87 int main(int argc
, char **argv
)
91 fd
= drm_open_matching("8086:*", 0);
93 fprintf(stderr
, "failed to open intel drm device\n");
98 test_create_close(fd
);
99 test_create_fd_close(fd
);