summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-02-19 14:48:31 +0100
committerJavier Jardón <jjardon@gnome.org>2014-11-21 15:27:26 +0000
commit7621ea52aa412fbc2f801d456004d6babb702df9 (patch)
tree387a9edc39a60a6e84bb9dd211ce41e48b19c5c5
parent84e209ffff5168956bf7e4578ff9a234c1c69425 (diff)
downloaddrm-7621ea52aa412fbc2f801d456004d6babb702df9.tar.gz
tegra: Add simple test for drm_tegra_open()
This test opens a device, dumps the version information and checks that a Tegra DRM context can be opened on it. Signed-off-by: Thierry Reding <treding@nvidia.com> --- Changes in v2: - fix in-tree build failure
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/tegra/.gitignore1
-rw-r--r--tests/tegra/Makefile.am22
-rw-r--r--tests/tegra/openclose.c63
5 files changed, 91 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index ac878feb..9c23cba5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -422,6 +422,7 @@ AC_CONFIG_FILES([
tests/radeon/Makefile
tests/vbltest/Makefile
tests/exynos/Makefile
+ tests/tegra/Makefile
man/Makefile
libdrm.pc])
AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd114913..0a3d21f2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,10 @@ if HAVE_EXYNOS
SUBDIRS += exynos
endif
+if HAVE_TEGRA
+SUBDIRS += tegra
+endif
+
if HAVE_LIBUDEV
check_LTLIBRARIES = libdrmtest.la
diff --git a/tests/tegra/.gitignore b/tests/tegra/.gitignore
new file mode 100644
index 00000000..5c5216c5
--- /dev/null
+++ b/tests/tegra/.gitignore
@@ -0,0 +1 @@
+openclose
diff --git a/tests/tegra/Makefile.am b/tests/tegra/Makefile.am
new file mode 100644
index 00000000..8b481bde
--- /dev/null
+++ b/tests/tegra/Makefile.am
@@ -0,0 +1,22 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include/drm \
+ -I$(top_srcdir)/tegra \
+ -I$(top_srcdir)
+
+AM_CFLAGS = -Wall -Werror
+
+LDADD = \
+ ../../tegra/libdrm_tegra.la \
+ ../../libdrm.la
+
+TESTS = \
+ openclose \
+
+if HAVE_INSTALL_TESTS
+testdir = $(libexecdir)/libdrm/tests/tegra
+test_PROGRAMS = \
+ $(TESTS)
+else
+noinst_PROGRAMS = $(TESTS)
+check_PROGRAMS = $(TESTS)
+endif
diff --git a/tests/tegra/openclose.c b/tests/tegra/openclose.c
new file mode 100644
index 00000000..5b4230c7
--- /dev/null
+++ b/tests/tegra/openclose.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2014 NVIDIA Corporation
+ *
+ * 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "xf86drm.h"
+#include "tegra.h"
+
+int main(int argc, char *argv[])
+{
+ struct drm_tegra *tegra;
+ drmVersionPtr version;
+ int err, fd;
+
+ fd = open(argv[1], O_RDWR);
+ if (fd < 0)
+ return 1;
+
+ version = drmGetVersion(fd);
+ if (version) {
+ printf("Version: %d.%d.%d\n", version->version_major,
+ version->version_minor, version->version_patchlevel);
+ printf(" Name: %s\n", version->name);
+ printf(" Date: %s\n", version->date);
+ printf(" Description: %s\n", version->desc);
+
+ drmFreeVersion(version);
+ }
+
+ err = drm_tegra_new(&tegra, fd);
+ if (err < 0)
+ return 1;
+
+ drm_tegra_close(tegra);
+ close(fd);
+
+ return 0;
+}