From patchwork Wed Mar 18 23:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11446265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEA19139A for ; Wed, 18 Mar 2020 23:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B557920773 for ; Wed, 18 Mar 2020 23:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584572796; bh=xmE3yElXSaLPkHmEr4QxRVGER8+rZ3BdqvEa3ZNkdF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=S1ibuUz3NltIZIJcxyImolRseK2mc8KUTLNIAF4WWP8LbIKXxel+aL821sszWMttA yss/5+ZdBFlh/1Xtl4UtSLNk37392CfZR2kMlzeGmArlpo8GXXnFlb2JXvGA3LGXhV lHF3PZJjSr0/wE3IrG+gKcbicxzVWhbBmXsde1uc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbgCRXGc (ORCPT ); Wed, 18 Mar 2020 19:06:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbgCRXGQ (ORCPT ); Wed, 18 Mar 2020 19:06:16 -0400 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FDBA2076F; Wed, 18 Mar 2020 23:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584572775; bh=xmE3yElXSaLPkHmEr4QxRVGER8+rZ3BdqvEa3ZNkdF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tBM+mtpjchueINOvzNZpxN2IDRCAxiG81X0PxlbMekTYiu9iXIIxqaIcKY8t+UnLo 2IrsiYs4JUcgA/C7duJWM0hZAqA7SEYXsFFNIP/1q2LSJIIPiWSv1gXgauA8f2t9cc +aChfDbgOhlxlLrgLWbzCkzQJbp7NM5ZljfPdHSI= From: Eric Biggers To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Alexei Starovoitov , Andrew Morton , Greg Kroah-Hartman , Jeff Vander Stoep , Jessica Yu , Kees Cook , Luis Chamberlain , NeilBrown Subject: [PATCH v4 4/5] selftests: kmod: fix handling test numbers above 9 Date: Wed, 18 Mar 2020 16:05:14 -0700 Message-Id: <20200318230515.171692-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318230515.171692-1-ebiggers@kernel.org> References: <20200318230515.171692-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Eric Biggers get_test_count() and get_test_enabled() were broken for test numbers above 9 due to awk interpreting a field specification like '$0010' as octal rather than decimal. Fix it by stripping the leading zeroes. Acked-by: Luis Chamberlain Cc: Alexei Starovoitov Cc: Andrew Morton Cc: Greg Kroah-Hartman Cc: Jeff Vander Stoep Cc: Jessica Yu Cc: Kees Cook Cc: NeilBrown Signed-off-by: Eric Biggers --- tools/testing/selftests/kmod/kmod.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh index 8b944cf042f6c..315a43111e046 100755 --- a/tools/testing/selftests/kmod/kmod.sh +++ b/tools/testing/selftests/kmod/kmod.sh @@ -505,18 +505,23 @@ function test_num() fi } -function get_test_count() +function get_test_data() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + local field_num=$(echo $1 | sed 's/^0*//') + echo $ALL_TESTS | awk '{print $'$field_num'}' +} + +function get_test_count() +{ + TEST_DATA=$(get_test_data $1) LAST_TWO=${TEST_DATA#*:*} echo ${LAST_TWO%:*} } function get_test_enabled() { - test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + TEST_DATA=$(get_test_data $1) echo ${TEST_DATA#*:*:} }