diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2010-01-08 15:34:44 +0000 |
---|---|---|
committer | Jakob Bornecrantz <jakob@vmware.com> | 2010-01-08 15:34:44 +0000 |
commit | d207a38701d664ac818829249d4d2566349bb359 (patch) | |
tree | 975a6c11f340cfede22430cb999113ce220da72b | |
parent | 8838bb1d63bdb8ffa808cd41b7e0ffd2e62ff7bc (diff) |
tests: Add a very small libkms test
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/kmstest/Makefile.am | 17 | ||||
-rw-r--r-- | tests/kmstest/main.c | 82 |
5 files changed, 105 insertions, 0 deletions
@@ -74,3 +74,4 @@ tests/setversion tests/updatedraw tests/modeprint/modeprint tests/modetest/modetest +tests/kmstest/kmstest diff --git a/configure.ac b/configure.ac index 9bad81a2..d3dc1542 100644 --- a/configure.ac +++ b/configure.ac @@ -227,6 +227,7 @@ AC_OUTPUT([ tests/Makefile tests/modeprint/Makefile tests/modetest/Makefile + tests/kmstest/Makefile include/Makefile include/drm/Makefile libdrm.pc]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4e4882ab..3e74705e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,10 @@ noinst_PROGRAMS = \ SUBDIRS = +if HAVE_LIBKMS +SUBDIRS += kmstest +endif + if HAVE_INTEL endif diff --git a/tests/kmstest/Makefile.am b/tests/kmstest/Makefile.am new file mode 100644 index 00000000..ae562a10 --- /dev/null +++ b/tests/kmstest/Makefile.am @@ -0,0 +1,17 @@ +AM_CFLAGS = \ + -I$(top_srcdir)/include/drm \ + -I$(top_srcdir)/libkms/ \ + -I$(top_srcdir) + +noinst_PROGRAMS = \ + kmstest + +kmstest_SOURCES = \ + main.c + +kmstest_LDADD = \ + $(top_builddir)/libdrm.la \ + $(top_builddir)/libkms/libkms.la + +run: kmstest + ./kmstest diff --git a/tests/kmstest/main.c b/tests/kmstest/main.c new file mode 100644 index 00000000..a9023990 --- /dev/null +++ b/tests/kmstest/main.c @@ -0,0 +1,82 @@ +/************************************************************************** + * + * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include <stdio.h> +#include <string.h> +#include "xf86drm.h" +#include "libkms.h" + +#define CHECK_RET_RETURN(ret, str) \ + if (ret) { \ + printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \ + return ret; \ + } + +int test_bo(struct kms_driver *kms) +{ + struct kms_bo *bo; + int ret; + unsigned attrs[7] = { + KMS_WIDTH, 1024, + KMS_HEIGHT, 768, + KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT, + KMS_TERMINATE_PROP_LIST, + }; + + ret = kms_bo_create(kms, attrs, &bo); + CHECK_RET_RETURN(ret, "Could not create bo"); + + kms_bo_destroy(&bo); + + return 0; +} + +int main(int argc, char** argv) +{ + struct kms_driver *kms; + int ret, fd; + + fd = drmOpen("i915", NULL); + CHECK_RET_RETURN(ret, "Could not open device"); + + ret = kms_create(fd, &kms); + CHECK_RET_RETURN(ret, "Failed to create kms driver"); + + ret = test_bo(kms); + if (ret) + goto err; + + printf("%s: All ok!\n", __func__); + + kms_destroy(&kms); + return 0; + +err: + kms_destroy(&kms); + return ret; +} |