From patchwork Wed Sep 13 09:24:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9950819 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 06EA76024A for ; Wed, 13 Sep 2017 09:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED04729043 for ; Wed, 13 Sep 2017 09:24:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1619290B4; Wed, 13 Sep 2017 09:24:30 +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 6C9A8290A2 for ; Wed, 13 Sep 2017 09:24:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B857D89FC0; Wed, 13 Sep 2017 09:24:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 543598908E for ; Wed, 13 Sep 2017 09:24:28 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 13 Sep 2017 02:24:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,387,1500966000"; d="scan'208"; a="1218181827" Received: from abdiel-macbookpro.fi.intel.com ([10.237.66.47]) by fmsmga002.fm.intel.com with ESMTP; 13 Sep 2017 02:24:26 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Sep 2017 12:24:18 +0300 Message-Id: <20170913092418.4442-1-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.9.3 Subject: [Intel-gfx] [PATCH i-g-t] tests/tools_test: Make sure l3_parity is supported 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 v3: Don't pipe the output of intel_l3_parity, parse it's output directly. (Petri) v2: Check support before executing test. Skip test only if intel_l3_parity tool tells us to skip. (Petri) bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101650 Cc: Petri Latvala Signed-off-by: Abdiel Janulgue Reviewed-by: Petri Latvala --- tests/tools_test.c | 64 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/tests/tools_test.c b/tests/tools_test.c index 1baf60b..572d5f4 100644 --- a/tests/tools_test.c +++ b/tests/tools_test.c @@ -27,23 +27,26 @@ #include #include +struct line_check { + bool found; + const char *substr; +}; + /** - * Parse the r-value of a [cmd] string. + * Our igt_log_buffer_inspect handler. Checks the output of the + * intel_l3_parity tool and returns true if a specific substring + * is found. */ -static bool check_cmd_return_value(const char *s, void *data) +static bool check_cmd_return_value(const char *line, void *data) { - int *val = data; - char *cmd, *found; - const char *delim = "[cmd]"; - const int delim_len = strlen(delim); + struct line_check *check = data; - if (!(cmd = strstr(s, delim))) + if (!strstr(line, check->substr)) { + check->found = false; return false; + } - found = cmd + delim_len + 1; - igt_assert(delim_len + strlen(found) < strlen(cmd)); - - *val = atoi(found); + check->found = true; return true; } @@ -57,37 +60,42 @@ igt_main igt_system_cmd(exec_return, "../tools/intel_l3_parity -r 0 -b 0 " "-s 0 -e"); - igt_assert(exec_return == IGT_EXIT_SUCCESS); + igt_skip_on_f(exec_return == IGT_EXIT_SKIP, + "intel_l3_parity not supported\n"); + igt_assert_eq(exec_return, IGT_EXIT_SUCCESS); - igt_system_cmd(exec_return, - "../tools/intel_l3_parity -l | " - "grep -c 'Row 0, Bank 0, Subbank 0 " - "is disabled'"); + igt_system_cmd(exec_return, "../tools/intel_l3_parity -l"); if (exec_return == IGT_EXIT_SUCCESS) { - int val = -1; + struct line_check line; + line.substr = "Row 0, Bank 0, Subbank 0 is disabled"; igt_log_buffer_inspect(check_cmd_return_value, - &val); - igt_assert(val == 1); - } else { - igt_fail(IGT_EXIT_FAILURE); + &line); + igt_assert_eq(line.found, true); } igt_system_cmd(exec_return, "../tools/intel_l3_parity -r 0 -b 0 " "-s 0 -e"); - igt_assert(exec_return == IGT_EXIT_SUCCESS); + igt_skip_on_f(exec_return == IGT_EXIT_SKIP, + "intel_l3_parity not supported\n"); + igt_assert_eq(exec_return, IGT_EXIT_SUCCESS); - /* Check that we can clear remaps */ + /* Check that we can clear remaps: + * In the original shell script, the output of intel_l3_parity -l + * was piped thru wc -l to check if the tool would at least + * return a line. Just watch for one of the expected output + * string as an alternative. + * ("is disabled" unique only to intel_l3_parity.c:dumpit()) + */ igt_system_cmd(exec_return, "../tools/intel_l3_parity -l | " "wc -l"); if (exec_return == IGT_EXIT_SUCCESS) { - int val = -1; + struct line_check line; + line.substr = "is disabled"; igt_log_buffer_inspect(check_cmd_return_value, - &val); - igt_assert(val == 1); - } else { - igt_fail(IGT_EXIT_FAILURE); + &line); + igt_assert_eq(line.found, true); } }