aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Agner2015-12-19 23:52:58 -0600
committerEmil Velikov2016-01-26 15:45:46 -0600
commit0caf58a6cb82327a3f6a53f05dea8e02f1412a05 (patch)
tree0d7ce05bd8183982c451600fd9c5b5508255eb87 /tests/kmstest
parent798022b61c58d945f9027c823a188dcedecd3d06 (diff)
downloadexternal-libgbm-0caf58a6cb82327a3f6a53f05dea8e02f1412a05.tar.gz
external-libgbm-0caf58a6cb82327a3f6a53f05dea8e02f1412a05.tar.xz
external-libgbm-0caf58a6cb82327a3f6a53f05dea8e02f1412a05.zip
kmstest: Use util_open()
Use the new util_open() helper instead of open-coding the method for finding a usable device. While at it, make the command-line interface more consistent with that of modetest by adding the -D and -M options. Signed-off-by: Stefan Agner <stefan@agner.ch> v2: correctly use util_open() - swap device, module Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'tests/kmstest')
-rw-r--r--tests/kmstest/Makefile.am4
-rw-r--r--tests/kmstest/main.c45
2 files changed, 32 insertions, 17 deletions
diff --git a/tests/kmstest/Makefile.am b/tests/kmstest/Makefile.am
index fd21e612..100662e4 100644
--- a/tests/kmstest/Makefile.am
+++ b/tests/kmstest/Makefile.am
@@ -2,6 +2,7 @@ AM_CFLAGS = \
2 $(WARN_CFLAGS)\ 2 $(WARN_CFLAGS)\
3 -I$(top_srcdir)/include/drm \ 3 -I$(top_srcdir)/include/drm \
4 -I$(top_srcdir)/libkms/ \ 4 -I$(top_srcdir)/libkms/ \
5 -I$(top_srcdir)/tests/ \
5 -I$(top_srcdir) 6 -I$(top_srcdir)
6 7
7if HAVE_INSTALL_TESTS 8if HAVE_INSTALL_TESTS
@@ -17,7 +18,8 @@ kmstest_SOURCES = \
17 18
18kmstest_LDADD = \ 19kmstest_LDADD = \
19 $(top_builddir)/libdrm.la \ 20 $(top_builddir)/libdrm.la \
20 $(top_builddir)/libkms/libkms.la 21 $(top_builddir)/libkms/libkms.la \
22 $(top_builddir)/tests/util/libutil.la
21 23
22run: kmstest 24run: kmstest
23 ./kmstest 25 ./kmstest
diff --git a/tests/kmstest/main.c b/tests/kmstest/main.c
index 120bc0fa..a0e4ebbd 100644
--- a/tests/kmstest/main.c
+++ b/tests/kmstest/main.c
@@ -25,12 +25,14 @@
25 * 25 *
26 **************************************************************************/ 26 **************************************************************************/
27 27
28 28#include <getopt.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <string.h> 30#include <string.h>
31#include "xf86drm.h" 31#include "xf86drm.h"
32#include "libkms.h" 32#include "libkms.h"
33 33
34#include "util/kms.h"
35
34#define CHECK_RET_RETURN(ret, str) \ 36#define CHECK_RET_RETURN(ret, str) \
35 if (ret < 0) { \ 37 if (ret < 0) { \
36 printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \ 38 printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \
@@ -56,26 +58,37 @@ static int test_bo(struct kms_driver *kms)
56 return 0; 58 return 0;
57} 59}
58 60
59static const char *drivers[] = { 61static void usage(const char *program)
60 "i915", 62{
61 "radeon", 63 fprintf(stderr, "Usage: %s [options]\n", program);
62 "nouveau", 64 fprintf(stderr, "\n");
63 "vmwgfx", 65 fprintf(stderr, " -D DEVICE open the given device\n");
64 "exynos", 66 fprintf(stderr, " -M MODULE open the given module\n");
65 "amdgpu", 67}
66 "imx-drm",
67 "rockchip",
68 "atmel-hlcdc",
69 NULL
70};
71 68
72int main(int argc, char** argv) 69int main(int argc, char** argv)
73{ 70{
71 static const char optstr[] = "D:M:";
74 struct kms_driver *kms; 72 struct kms_driver *kms;
75 int ret, fd, i; 73 int c, fd, ret;
74 char *device = NULL;
75 char *module = NULL;
76
77 while ((c = getopt(argc, argv, optstr)) != -1) {
78 switch (c) {
79 case 'D':
80 device = optarg;
81 break;
82 case 'M':
83 module = optarg;
84 break;
85 default:
86 usage(argv[0]);
87 return 0;
88 }
89 }
76 90
77 for (i = 0, fd = -1; fd < 0 && drivers[i]; i++) 91 fd = util_open(device, module);
78 fd = drmOpen(drivers[i], NULL);
79 CHECK_RET_RETURN(fd, "Could not open device"); 92 CHECK_RET_RETURN(fd, "Could not open device");
80 93
81 ret = kms_create(fd, &kms); 94 ret = kms_create(fd, &kms);