From patchwork Tue Jan 8 11:16:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 1945331 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 829973FC5A for ; Tue, 8 Jan 2013 11:16:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65091E63EE for ; Tue, 8 Jan 2013 03:16:21 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id E09CAE5E9F for ; Tue, 8 Jan 2013 03:16:13 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 08 Jan 2013 03:16:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,430,1355126400"; d="scan'208";a="274206129" Received: from gaia.fi.intel.com (HELO gaia) ([10.237.72.179]) by fmsmga002.fm.intel.com with ESMTP; 08 Jan 2013 03:16:12 -0800 Received: by gaia (Postfix, from userid 1000) id 8882F40016; Tue, 8 Jan 2013 13:16:11 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Tue, 8 Jan 2013 13:16:06 +0200 Message-Id: <1357643766-14614-1-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 Subject: [Intel-gfx] [PATCH] tests/gem_seqno_wrap: skip if debugfs entry is not there X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Return error code 77 to skip test if debugfs entry is not available. Signed-off-by: Mika Kuoppala --- tests/gem_seqno_wrap.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c index 76a1723..43e3851 100644 --- a/tests/gem_seqno_wrap.c +++ b/tests/gem_seqno_wrap.c @@ -49,6 +49,7 @@ #include "rendercopy.h" static int devid; +static int card_index = 0; static uint32_t last_seqno = 0; static struct intel_batchbuffer *batch_blt; @@ -355,7 +356,27 @@ static int run_cmd(char *s) return r; } -static const char *debug_fs_entry = "/sys/kernel/debug/dri/0/i915_next_seqno"; +static const char *dfs_base = "/sys/kernel/debug/dri"; +static const char *dfs_entry = "i915_next_seqno"; + +static int dfs_open(int mode) +{ + char fname[FILENAME_MAX]; + int fh; + + snprintf(fname, FILENAME_MAX, "%s/%i/%s", + dfs_base, card_index, dfs_entry); + + fh = open(fname, mode); + if (fh == -1) { + fprintf(stderr, + "error %d opening '%s/%d/%s'. too old kernel?\n", + errno, dfs_base, card_index, dfs_entry); + exit(77); + } + + return fh; +} static int __read_seqno(uint32_t *seqno) { @@ -365,12 +386,7 @@ static int __read_seqno(uint32_t *seqno) char *p; unsigned long int tmp; - fh = open(debug_fs_entry, O_RDWR); - if (fh == -1) { - perror("open"); - fprintf(stderr, "no %s found, too old kernel?\n", debug_fs_entry); - return -errno; - } + fh = dfs_open(O_RDONLY); r = read(fh, buf, sizeof(buf) - 1); close(fh); @@ -385,8 +401,9 @@ static int __read_seqno(uint32_t *seqno) if (!p) p = buf; + errno = 0; tmp = strtoul(p, NULL, 0); - if (tmp == ULONG_MAX) { + if (tmp == ULONG_MAX && errno) { perror("strtoul"); return -errno; } @@ -425,12 +442,7 @@ static int write_seqno(uint32_t seqno) if (options.dontwrap) return 0; - fh = open(debug_fs_entry, O_RDWR); - if (fh == -1) { - perror("open"); - return -errno; - } - + fh = dfs_open(O_RDWR); assert(snprintf(buf, sizeof(buf), "0x%x", seqno) > 0); r = write(fh, buf, strnlen(buf, sizeof(buf))); @@ -627,6 +639,9 @@ int main(int argc, char **argv) parse_options(argc, argv); + card_index = drm_get_card(0); + assert(card_index != -1); + srandom(time(NULL)); while(options.rounds == 0 || wcount < options.rounds) {