[Intel-gfx] [i-g-t PATCH] Convert ddx_intel_after_fbdev to C.

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Tue Apr 25 09:54:33 UTC 2017


Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 tests/Makefile.sources        |   1 +
 tests/ddx_intel_after_fbdev   |  73 -------------------------
 tests/ddx_intel_after_fbdev.c | 121 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 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 f646050..80cb02b 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -235,6 +235,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..8049a1a
--- /dev/null
+++ b/tests/ddx_intel_after_fbdev.c
@@ -0,0 +1,121 @@
+/*
+ * 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>
+
+#define exec_cmd(status, format...) \
+	do { \
+		char *buf = 0; \
+		igt_assert(asprintf(&buf, format) != -1); \
+	        status = igt_exec(buf); \
+		free(buf); \
+	} while (0)
+
+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 */
+	exec_cmd(status, "dmesg -c > %s/dmesg.1.before.fbdev", tmpdir);
+	exec_cmd(status, "cp /var/log/Xorg.0.log "
+			   "%s/Xorg.0.log.1.before.fbdev", tmpdir);
+
+	/* run fbdev */
+	exec_cmd(status, "xinit -- /usr/bin/X -config "
+			   "%s/xorg.conf.fbdev &", tmpdir);
+	sleep(5);
+	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 */
+	exec_cmd(status, "dmesg -c > %s/dmesg.2.after.fbdev.before.intel",
+		 tmpdir);
+	exec_cmd(status, "cp /var/log/Xorg.0.log "
+		 "%s/Xorg.0.log.2.after.fbdev.before.intel", tmpdir);
+	sleep(5);
+
+	/* run intel */
+	exec_cmd(status, "xinit -- /usr/bin/X -config "
+			   "%s/xorg.conf.intel &", tmpdir);
+	sleep(5);
+	igt_exec_quiet("killall -r X");
+	sleep(1);
+	exec_cmd(status, "../tools/intel_reg dump > "
+			   "%s/intel_reg_dump.2.intel", tmpdir);
+
+	/* log after intel */
+	exec_cmd(status, "dmesg -c > %s/dmesg.3.after.intel", tmpdir);
+	exec_cmd(status, "cp /var/log/Xorg.0.log %s/Xorg.0.log.3.after.intel",
+		 tmpdir);
+
+	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



More information about the Intel-gfx mailing list