All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [i-g-t PATCH v2 4/4] Convert ddx_intel_after_fbdev to C.
Date: Mon, 29 May 2017 15:08:10 +0300	[thread overview]
Message-ID: <1496059690-3308-4-git-send-email-abdiel.janulgue@linux.intel.com> (raw)
In-Reply-To: <1496059690-3308-1-git-send-email-abdiel.janulgue@linux.intel.com>

v2: Use igt_exec_cmd macro.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
 tests/Makefile.sources        |   1 +
 tests/ddx_intel_after_fbdev   |  73 ---------------------------
 tests/ddx_intel_after_fbdev.c | 113 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 114 insertions(+), 73 deletions(-)
 delete mode 100755 tests/ddx_intel_after_fbdev
 create mode 100644 tests/ddx_intel_after_fbdev.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c4a78a9..8068257 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -245,6 +245,7 @@ TESTS_progs = \
 	perf \
 	debugfs \
 	tools \
+	ddx_intel_after_fbdev \
 	$(NULL)
 
 # IMPORTANT: The ZZ_ tests need to be run last!
diff --git a/tests/ddx_intel_after_fbdev b/tests/ddx_intel_after_fbdev
deleted file mode 100755
index f068209..0000000
--- a/tests/ddx_intel_after_fbdev
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/bash
-#
-# Testcase: Load Intel DDX after fbdev was loaded
-#
-
-whoami | grep -q root || {
-	echo "ERROR: not running as root"
-	exit 1
-}
-
-# no other X session should be running
-find /tmp/ -name .X*lock 2>/dev/null | grep -q X && {
-	echo "ERROR: X session already running"
-	exit 1
-}
-
-TMPDIR=$(mktemp -d /tmp/igt.XXXX) || {
-	echo "ERROR: Failed to create temp dir"
-	exit 1
-}
-
-cat > $TMPDIR/xorg.conf.fbdev << EOF
-Section "Device"
-	Driver		"fbdev"
-	Identifier 	"Device[fbdev]"
-EndSection
-EOF
-
-cat > $TMPDIR/xorg.conf.intel << EOF
-Section "Device"
-	Driver		"intel"
-	Identifier 	"Device[intel]"
-EndSection
-EOF
-
-# log before fbdev
-dmesg -c > $TMPDIR/dmesg.1.before.fbdev
-cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.1.before.fbdev
-
-# run fbdev
-xinit -- /usr/bin/X -config $TMPDIR/xorg.conf.fbdev & 
-sleep 5
-if [ -f `which intel_reg` ]; then
-`which intel_reg` dump > $TMPDIR/intel_reg_dump.1.fbdev
-fi
-killall X
-
-# log after fbdev & before intel
-dmesg -c > $TMPDIR/dmesg.2.after.fbdev.before.intel
-cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.2.after.fbdev.before.intel
-
-sleep 5
-
-# run intel
-xinit -- /usr/bin/X -config $TMPDIR/xorg.conf.intel & 
-sleep 5 
-if [ -f `which intel_reg` ]; then
-`which intel_reg` dump > $TMPDIR/intel_reg_dump.2.intel
-fi
-killall X
-
-# log after intel
-dmesg -c > $TMPDIR/dmesg.3.after.intel
-cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.3.after.intel
-
-cp $0 $TMPDIR/
-
-tar czf $TMPDIR.tar.gz $TMPDIR/*
-if [ -f $TMPDIR.tar.gz ]; then
-	echo $TMPDIR.tar.gz contains this script, all configs and logs generated on this tests
-fi
-
-exit 0
diff --git a/tests/ddx_intel_after_fbdev.c b/tests/ddx_intel_after_fbdev.c
new file mode 100644
index 0000000..b22f8d8
--- /dev/null
+++ b/tests/ddx_intel_after_fbdev.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 2017 Intel 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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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 "igt.h"
+#include <unistd.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+	int status;
+	FILE *file;
+	char *path;
+	const char xorg_fbdev[] =
+		"Section  \"Device\"\n"
+		"          Driver        \"fbdev\"\n"
+		"          Identifier 	 \"Device[fbdev]\"\n"
+		"EndSection\n";
+	const char xorg_intel[] =
+		"Section   \"Device\"\n"
+		"          Driver        \"intel\"\n"
+		"          Identifier 	 \"Device[intel]\"\n"
+		"EndSection\n";
+	char *tmpdir = strdup("/tmp/igt.XXXXXX");
+
+	igt_skip_on_simulation();
+
+	igt_assert_f(getuid() == 0, "ERROR: not running as root\n");
+
+	igt_assert_f(igt_exec_quiet("find /tmp/ -name .X*lock | grep -q X")
+		     != IGT_EXIT_SUCCESS,
+		     "ERROR: X session already running\n");
+
+	igt_assert_f(mkdtemp(tmpdir) != NULL,
+		     "ERROR: Failed to create temp dir\n");
+
+	/* config files */
+	igt_assert(asprintf(&path, "%s/xorg.conf.fbdev", tmpdir) != -1);
+	igt_assert((file = fopen(path, "w")) != NULL);
+	fwrite(xorg_fbdev, 1, sizeof(xorg_fbdev), file);
+	free(path);
+	fclose(file);
+
+	igt_assert(asprintf(&path, "%s/xorg.conf.intel", tmpdir) != -1);
+	igt_assert((file = fopen(path, "w")) != NULL);
+	fwrite(xorg_intel, 1, sizeof(xorg_intel), file);
+	free(path);
+	fclose(file);
+
+	/* log before fbdev */
+	igt_exec_cmd(status, "dmesg -c > %s/dmesg.1.before.fbdev", tmpdir);
+	igt_exec_cmd(status, "cp /var/log/Xorg.0.log "
+			   "%s/Xorg.0.log.1.before.fbdev", tmpdir);
+
+	/* run fbdev */
+	igt_exec_cmd(status, "xinit -- /usr/bin/X -config "
+			   "%s/xorg.conf.fbdev &", tmpdir);
+	sleep(5);
+	igt_exec_cmd(status, "../tools/intel_reg dump > "
+			   "%s/intel_reg_dump.1.fbdev", tmpdir);
+	igt_exec_quiet("killall -r X");
+
+	/* log after fbdev & before intel */
+	igt_exec_cmd(status, "dmesg -c > %s/dmesg.2.after.fbdev.before.intel",
+		 tmpdir);
+	igt_exec_cmd(status, "cp /var/log/Xorg.0.log "
+		 "%s/Xorg.0.log.2.after.fbdev.before.intel", tmpdir);
+	sleep(5);
+
+	/* run intel */
+	igt_exec_cmd(status, "xinit -- /usr/bin/X -config "
+			   "%s/xorg.conf.intel &", tmpdir);
+	sleep(5);
+	igt_exec_quiet("killall -r X");
+	sleep(1);
+	igt_exec_cmd(status, "../tools/intel_reg dump > "
+			   "%s/intel_reg_dump.2.intel", tmpdir);
+
+	/* log after intel */
+	igt_exec_cmd(status, "dmesg -c > %s/dmesg.3.after.intel", tmpdir);
+	igt_exec_cmd(status, "cp /var/log/Xorg.0.log %s/Xorg.0.log.3.after.intel",
+		 tmpdir);
+
+	igt_exec_cmd(status, "tar czf %s.tar.gz %s/*", tmpdir, tmpdir);
+	if (status == IGT_EXIT_SUCCESS) {
+		igt_info("%s.tar.gz contains this script, all configs "
+			 "and logs generated on this tests\n", tmpdir);
+	}
+	free(tmpdir);
+
+	igt_exit();
+}
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-05-29 12:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 12:08 [i-g-t PATCH v2 1/4] lib/igt_core: Add igt_exec helpers Abdiel Janulgue
2017-05-29 12:08 ` [i-g-t PATCH v2 2/4] igt/igt_core: Provide an option to check for the log buffer contents Abdiel Janulgue
2017-05-29 12:08 ` [i-g-t PATCH v2 3/4] Convert shell script tests to C version Abdiel Janulgue
2017-05-29 13:00   ` Chris Wilson
2017-05-29 12:08 ` Abdiel Janulgue [this message]
2017-05-29 13:07   ` [i-g-t PATCH v2 4/4] Convert ddx_intel_after_fbdev to C Chris Wilson
2017-05-29 13:01 ` [i-g-t PATCH v2 1/4] lib/igt_core: Add igt_exec helpers Chris Wilson
2017-05-30 10:31   ` Abdiel Janulgue
2017-05-30 10:55     ` Chris Wilson

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=1496059690-3308-4-git-send-email-abdiel.janulgue@linux.intel.com \
    --to=abdiel.janulgue@linux.intel.com \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.