From patchwork Mon May 29 12:08:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9753139 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 7F55160249 for ; Mon, 29 May 2017 12:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BFD523B24 for ; Mon, 29 May 2017 12:10:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F64423F88; Mon, 29 May 2017 12:10:13 +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 0557A23B24 for ; Mon, 29 May 2017 12:10:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80CB089B38; Mon, 29 May 2017 12:10:11 +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 E41F489B38 for ; Mon, 29 May 2017 12:10:09 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2017 05:10:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.38,414,1491289200"; d="scan'208"; a="1154104082" Received: from skylake-nuc.fi.intel.com ([10.237.72.145]) by fmsmga001.fm.intel.com with ESMTP; 29 May 2017 05:10:08 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Mon, 29 May 2017 15:08:10 +0300 Message-Id: <1496059690-3308-4-git-send-email-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496059690-3308-1-git-send-email-abdiel.janulgue@linux.intel.com> References: <1496059690-3308-1-git-send-email-abdiel.janulgue@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [i-g-t PATCH v2 4/4] 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 v2: Use igt_exec_cmd macro. Signed-off-by: Abdiel Janulgue --- 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 +#include + +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(); +}