From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [RFC libdrm 3/6] tegra: Add simple test for drm_tegra_open()
Date: Wed, 19 Feb 2014 17:04:50 +0100 [thread overview]
Message-ID: <1392825893-7380-4-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1392825893-7380-1-git-send-email-thierry.reding@gmail.com>
From: Thierry Reding <treding@nvidia.com>
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>
---
configure.ac | 1 +
tests/Makefile.am | 4 ++++
tests/tegra/Makefile.am | 20 ++++++++++++++++
tests/tegra/openclose.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+)
create mode 100644 tests/tegra/Makefile.am
create mode 100644 tests/tegra/openclose.c
diff --git a/configure.ac b/configure.ac
index 752a70592933..c4ae14e8d2e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -421,6 +421,7 @@ AC_CONFIG_FILES([
tests/radeon/Makefile
tests/vbltest/Makefile
tests/exynos/Makefile
+ tests/tegra/Makefile
include/Makefile
include/drm/Makefile
man/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd1149130214..0a3d21f2d99f 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/Makefile.am b/tests/tegra/Makefile.am
new file mode 100644
index 000000000000..7039f09d38aa
--- /dev/null
+++ b/tests/tegra/Makefile.am
@@ -0,0 +1,20 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include/drm \
+ -I$(top_srcdir)/tegra
+
+AM_CFLAGS = -Wall -Werror
+
+LDADD = \
+ ../../tegra/libdrm_tegra.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 000000000000..5b4230c774f6
--- /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;
+}
--
1.8.4.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-02-19 16:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 16:04 [RFC libdrm 0/6] Add NVIDIA Tegra support Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 1/6] configure: Support symbol visibility when available Thierry Reding
2014-02-19 21:05 ` Erik Faye-Lund
2014-02-19 21:50 ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 2/6] libdrm: Add NVIDIA Tegra support Thierry Reding
2014-02-19 19:59 ` Rémi Cardona
2014-02-19 20:03 ` Erik Faye-Lund
2014-02-19 21:33 ` Thierry Reding
2014-02-19 20:13 ` Erik Faye-Lund
2014-02-19 21:32 ` Thierry Reding
2014-02-19 16:04 ` Thierry Reding [this message]
2014-02-19 20:19 ` [RFC libdrm 3/6] tegra: Add simple test for drm_tegra_open() Erik Faye-Lund
2014-02-19 20:50 ` Erik Faye-Lund
2014-02-19 21:34 ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 4/6] tegra: Add channel, job, pushbuf and fence APIs Thierry Reding
2014-02-19 19:57 ` Erik Faye-Lund
2014-02-19 21:11 ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 5/6] tegra: Add helper library for tests Thierry Reding
2014-02-19 20:54 ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 6/6] tegra: Add gr2d-fill test Thierry Reding
2014-02-19 21:03 ` Erik Faye-Lund
2014-02-19 21:49 ` Thierry Reding
2014-03-20 15:23 ` [RFC libdrm 0/6] Add NVIDIA Tegra support Erik Faye-Lund
2014-04-08 12:58 ` Erik Faye-Lund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392825893-7380-4-git-send-email-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox