mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-01-03 08:10:21 +01:00
[GEM] Update testcases for new API.
This commit is contained in:
parent
f650d7240a
commit
6e46a3c762
3 changed files with 38 additions and 40 deletions
|
|
@ -36,48 +36,48 @@
|
|||
#include "drm.h"
|
||||
|
||||
static void
|
||||
test_bad_unref(int fd)
|
||||
test_bad_close(int fd)
|
||||
{
|
||||
struct drm_gem_unreference unref;
|
||||
struct drm_gem_close close;
|
||||
int ret;
|
||||
|
||||
printf("Testing error return on bad unreference ioctl.\n");
|
||||
printf("Testing error return on bad close ioctl.\n");
|
||||
|
||||
unref.handle = 0x10101010;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_UNREFERENCE, &unref);
|
||||
close.handle = 0x10101010;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
|
||||
assert(ret == -1 && errno == EINVAL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_alloc_unref(int fd)
|
||||
test_create_close(int fd)
|
||||
{
|
||||
struct drm_gem_alloc alloc;
|
||||
struct drm_gem_unreference unref;
|
||||
struct drm_gem_create create;
|
||||
struct drm_gem_close close;
|
||||
int ret;
|
||||
|
||||
printf("Testing allocating and unreferencing an object.\n");
|
||||
printf("Testing creating and closing an object.\n");
|
||||
|
||||
memset(&alloc, 0, sizeof(alloc));
|
||||
alloc.size = 16 * 1024;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_ALLOC, &alloc);
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = 16 * 1024;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CREATE, &create);
|
||||
assert(ret == 0);
|
||||
|
||||
unref.handle = alloc.handle;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_UNREFERENCE, &unref);
|
||||
close.handle = create.handle;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
}
|
||||
|
||||
static void
|
||||
test_alloc_close(int fd)
|
||||
test_create_fd_close(int fd)
|
||||
{
|
||||
struct drm_gem_alloc alloc;
|
||||
struct drm_gem_create create;
|
||||
int ret;
|
||||
|
||||
printf("Testing closing with an object allocated.\n");
|
||||
|
||||
memset(&alloc, 0, sizeof(alloc));
|
||||
alloc.size = 16 * 1024;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_ALLOC, &alloc);
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = 16 * 1024;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CREATE, &create);
|
||||
assert(ret == 0);
|
||||
|
||||
close(fd);
|
||||
|
|
@ -89,11 +89,9 @@ int main(int argc, char **argv)
|
|||
|
||||
fd = drm_open_any();
|
||||
|
||||
test_bad_unref(fd);
|
||||
test_alloc_unref(fd);
|
||||
test_alloc_close(fd);
|
||||
|
||||
close(fd);
|
||||
test_bad_close(fd);
|
||||
test_create_close(fd);
|
||||
test_create_fd_close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ int do_write(int fd, int handle, void *buf, int offset, int size)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
struct drm_gem_alloc alloc;
|
||||
struct drm_gem_create create;
|
||||
struct drm_gem_mmap mmap;
|
||||
struct drm_gem_unreference unref;
|
||||
struct drm_gem_close unref;
|
||||
uint8_t expected[OBJECT_SIZE];
|
||||
uint8_t buf[OBJECT_SIZE];
|
||||
uint8_t *addr;
|
||||
|
|
@ -90,13 +90,13 @@ int main(int argc, char **argv)
|
|||
ret = ioctl(fd, DRM_IOCTL_GEM_MMAP, &mmap);
|
||||
assert(ret == -1 && errno == EINVAL);
|
||||
|
||||
memset(&alloc, 0, sizeof(alloc));
|
||||
alloc.size = OBJECT_SIZE;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_ALLOC, &alloc);
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = OBJECT_SIZE;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CREATE, &create);
|
||||
assert(ret == 0);
|
||||
handle = alloc.handle;
|
||||
handle = create.handle;
|
||||
|
||||
printf("Testing mmaping of newly allocated object.\n");
|
||||
printf("Testing mmaping of newly created object.\n");
|
||||
mmap.handle = handle;
|
||||
mmap.offset = 0;
|
||||
mmap.size = OBJECT_SIZE;
|
||||
|
|
@ -104,7 +104,7 @@ int main(int argc, char **argv)
|
|||
assert(ret == 0);
|
||||
addr = (uint8_t *)(uintptr_t)mmap.addr_ptr;
|
||||
|
||||
printf("Testing contents of newly allocated object.\n");
|
||||
printf("Testing contents of newly created object.\n");
|
||||
memset(expected, 0, sizeof(expected));
|
||||
assert(memcmp(addr, expected, sizeof(expected)) == 0);
|
||||
|
||||
|
|
@ -116,9 +116,9 @@ int main(int argc, char **argv)
|
|||
assert(ret == 0);
|
||||
assert(memcmp(buf, addr, sizeof(buf)) == 0);
|
||||
|
||||
printf("Testing that mapping stays after unreference\n");
|
||||
printf("Testing that mapping stays after close\n");
|
||||
unref.handle = handle;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_UNREFERENCE, &unref);
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &unref);
|
||||
assert(ret == 0);
|
||||
assert(memcmp(buf, addr, sizeof(buf)) == 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ int do_write(int fd, int handle, void *buf, int offset, int size)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
struct drm_gem_alloc alloc;
|
||||
struct drm_gem_create create;
|
||||
uint8_t expected[OBJECT_SIZE];
|
||||
uint8_t buf[OBJECT_SIZE];
|
||||
int ret;
|
||||
|
|
@ -79,13 +79,13 @@ int main(int argc, char **argv)
|
|||
|
||||
fd = drm_open_any();
|
||||
|
||||
memset(&alloc, 0, sizeof(alloc));
|
||||
alloc.size = OBJECT_SIZE;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_ALLOC, &alloc);
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = OBJECT_SIZE;
|
||||
ret = ioctl(fd, DRM_IOCTL_GEM_CREATE, &create);
|
||||
assert(ret == 0);
|
||||
handle = alloc.handle;
|
||||
handle = create.handle;
|
||||
|
||||
printf("Testing contents of newly allocated object.\n");
|
||||
printf("Testing contents of newly created object.\n");
|
||||
ret = do_read(fd, handle, buf, 0, OBJECT_SIZE);
|
||||
assert(ret == 0);
|
||||
memset(&expected, 0, sizeof(expected));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue