From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0273CC1975A for ; Sun, 15 Mar 2020 02:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C53D420575 for ; Sun, 15 Mar 2020 02:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584239115; bh=xmE3yElXSaLPkHmEr4QxRVGER8+rZ3BdqvEa3ZNkdF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UHFs9mvrCG3gUf+qZip9LlFPMyKraEiu/2VhoI0xwa7xTlaV5jwAUxJqxUpuizQ65 JM28DbqydbE7bxS2NPdnA6Lp1aBeFUDV6Iu6U63o5LsjiJmMpQhvIXLPjp/hpf57ZY XlOSgcuHYqodKqeVo1Wu9FWQpqJtgvhkIs/8J9VQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727889AbgCOCZI (ORCPT ); Sat, 14 Mar 2020 22:25:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbgCOCYN (ORCPT ); Sat, 14 Mar 2020 22:24:13 -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 145F7208D6; Sat, 14 Mar 2020 21:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584221809; bh=xmE3yElXSaLPkHmEr4QxRVGER8+rZ3BdqvEa3ZNkdF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0MEecr+36WP4z93qOCDFo9M69v6/l1BsgQinH+aiEM4rai3GplQEwS8cb+UrHWBk LsqY7T7PRhGCBhj3hbkypJk1PTzpzF4Qmy5BvyYEmoTgqmtQyg6GZA8AffyAVDPuGa JWdTj9Kjh3KSqiPNO/9FY/K6EfErk3WztFDe5IIY= 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 v3 4/5] selftests: kmod: fix handling test numbers above 9 Date: Sat, 14 Mar 2020 14:34:25 -0700 Message-Id: <20200314213426.134866-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200314213426.134866-1-ebiggers@kernel.org> References: <20200314213426.134866-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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#*:*:} } -- 2.25.1