From patchwork Tue Apr 25 09:54:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9697805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D18BE6020A for ; Tue, 25 Apr 2017 09:56:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C21B32857D for ; Tue, 25 Apr 2017 09:56:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6B0E2858D; Tue, 25 Apr 2017 09:56:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F6752857D for ; Tue, 25 Apr 2017 09:56:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D45936E308; Tue, 25 Apr 2017 09:56:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 329D26E307 for ; Tue, 25 Apr 2017 09:56:17 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2017 02:56:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,249,1488873600"; d="scan'208";a="253166413" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by fmsmga004.fm.intel.com with ESMTP; 25 Apr 2017 02:56:15 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Tue, 25 Apr 2017 12:54:33 +0300 Message-Id: <1493114073-5744-1-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492676028-15372-4-git-send-email-abdiel.janulgue@linux.intel.com> References: <1492676028-15372-4-git-send-email-abdiel.janulgue@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [i-g-t PATCH] Convert ddx_intel_after_fbdev to C. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Abdiel Janulgue --- 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 +#include + +#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(); +}