aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz2010-01-08 09:34:44 -0600
committerJakob Bornecrantz2010-01-08 09:34:44 -0600
commitd207a38701d664ac818829249d4d2566349bb359 (patch)
tree975a6c11f340cfede22430cb999113ce220da72b
parent8838bb1d63bdb8ffa808cd41b7e0ffd2e62ff7bc (diff)
downloadexternal-libdrm-d207a38701d664ac818829249d4d2566349bb359.tar.gz
external-libdrm-d207a38701d664ac818829249d4d2566349bb359.tar.xz
external-libdrm-d207a38701d664ac818829249d4d2566349bb359.zip
tests: Add a very small libkms test
-rw-r--r--.gitignore1
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/kmstest/Makefile.am17
-rw-r--r--tests/kmstest/main.c82
5 files changed, 105 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 2832fc2d..5f9c1fa8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,3 +74,4 @@ tests/setversion
74tests/updatedraw 74tests/updatedraw
75tests/modeprint/modeprint 75tests/modeprint/modeprint
76tests/modetest/modetest 76tests/modetest/modetest
77tests/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([
227 tests/Makefile 227 tests/Makefile
228 tests/modeprint/Makefile 228 tests/modeprint/Makefile
229 tests/modetest/Makefile 229 tests/modetest/Makefile
230 tests/kmstest/Makefile
230 include/Makefile 231 include/Makefile
231 include/drm/Makefile 232 include/drm/Makefile
232 libdrm.pc]) 233 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 = \
12 12
13SUBDIRS = 13SUBDIRS =
14 14
15if HAVE_LIBKMS
16SUBDIRS += kmstest
17endif
18
15if HAVE_INTEL 19if HAVE_INTEL
16endif 20endif
17 21
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 @@
1AM_CFLAGS = \
2 -I$(top_srcdir)/include/drm \
3 -I$(top_srcdir)/libkms/ \
4 -I$(top_srcdir)
5
6noinst_PROGRAMS = \
7 kmstest
8
9kmstest_SOURCES = \
10 main.c
11
12kmstest_LDADD = \
13 $(top_builddir)/libdrm.la \
14 $(top_builddir)/libkms/libkms.la
15
16run: kmstest
17 ./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 @@
1/**************************************************************************
2 *
3 * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29#include <stdio.h>
30#include <string.h>
31#include "xf86drm.h"
32#include "libkms.h"
33
34#define CHECK_RET_RETURN(ret, str) \
35 if (ret) { \
36 printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \
37 return ret; \
38 }
39
40int test_bo(struct kms_driver *kms)
41{
42 struct kms_bo *bo;
43 int ret;
44 unsigned attrs[7] = {
45 KMS_WIDTH, 1024,
46 KMS_HEIGHT, 768,
47 KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT,
48 KMS_TERMINATE_PROP_LIST,
49 };
50
51 ret = kms_bo_create(kms, attrs, &bo);
52 CHECK_RET_RETURN(ret, "Could not create bo");
53
54 kms_bo_destroy(&bo);
55
56 return 0;
57}
58
59int main(int argc, char** argv)
60{
61 struct kms_driver *kms;
62 int ret, fd;
63
64 fd = drmOpen("i915", NULL);
65 CHECK_RET_RETURN(ret, "Could not open device");
66
67 ret = kms_create(fd, &kms);
68 CHECK_RET_RETURN(ret, "Failed to create kms driver");
69
70 ret = test_bo(kms);
71 if (ret)
72 goto err;
73
74 printf("%s: All ok!\n", __func__);
75
76 kms_destroy(&kms);
77 return 0;
78
79err:
80 kms_destroy(&kms);
81 return ret;
82}