From patchwork Thu Feb 23 01:26:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 9587637 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 64FD160578 for ; Thu, 23 Feb 2017 01:26:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 523362860C for ; Thu, 23 Feb 2017 01:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46C2628670; Thu, 23 Feb 2017 01:26:34 +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 370062860C for ; Thu, 23 Feb 2017 01:26:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F29C56E91B; Thu, 23 Feb 2017 01:26:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA61A6E91B for ; Thu, 23 Feb 2017 01:26:29 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2017 17:26:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,197,1484035200"; d="scan'208";a="51555194" Received: from relo-linux-11.sc.intel.com ([10.3.160.214]) by orsmga002.jf.intel.com with ESMTP; 22 Feb 2017 17:26:29 -0800 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Wed, 22 Feb 2017 17:26:29 -0800 Message-Id: <20170223012629.13734-1-michel.thierry@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/drv_hangman: Fix clear_error_state 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP clear_error_state was not doing anything (igt_sysfs_set was not writing to the error file). Also fix assert_entry to catch this issue; strcasecmp returns 0 when there's a match, or an integer in a mismatch. Finally, only print part of the error string when the assert fails. Cc: Chris Wilson Fixes: 79c6a84ca85b ("igt/drv_hangman: Migrate to sysfs") Signed-off-by: Michel Thierry --- tests/drv_hangman.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c index cafdf4c1..43f73661 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -58,9 +58,15 @@ static void assert_entry(const char *s, bool expect) error = igt_sysfs_get(sysfs, "error"); igt_assert(error); - igt_assert_f(strcasecmp(error, s) != expect, - "contents of error: '%s' (expected %s '%s')\n", - error, expect ? "": "not", s); + if (expect) { + igt_assert_f(strcasecmp(error, s) == 0, + "contents of error: '%.24s' (expected %s '%s')\n", + error, expect ? "": "not", s); + } else { + igt_assert_f(strcasecmp(error, s) != 0, + "contents of error: '%.24s' (expected %s '%s')\n", + error, expect ? "": "not", s); + } free(error); } @@ -77,7 +83,7 @@ static void assert_error_state_collected(void) static void clear_error_state(void) { - igt_sysfs_set(sysfs, "error", ""); + igt_sysfs_set(sysfs, "error", " "); } static void test_error_state_basic(void)