From patchwork Fri Jun 2 11:06:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AA2FC77B7A for ; Fri, 2 Jun 2023 11:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235869AbjFBLHf (ORCPT ); Fri, 2 Jun 2023 07:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235827AbjFBLH0 (ORCPT ); Fri, 2 Jun 2023 07:07:26 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6863513E for ; Fri, 2 Jun 2023 04:07:01 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110645euoutp02fe0bb8e2aef326877430a41326e4cfe6~k0tys80l52930329303euoutp02t for ; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602110645euoutp02fe0bb8e2aef326877430a41326e4cfe6~k0tys80l52930329303euoutp02t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704005; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=lcErz3Znew6Cqgq6ClEyB0FClsY3UnYnjd0HLH70Qz3y2F9yhnV3JaRUXWBniT47r u++2iOnhmF0rlaTnXDYEx223Mo1dGpcbe+Xapd8uuLQnJ4NyJeM1bINIY+0PJCanCd 6NFT30IHbGkWNHfw2pOnXwiWNVjfSKBccKG3m+ec= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110645eucas1p2443fb17acbed500c524607354f4e339f~k0tyoJ_Bo0783007830eucas1p2P; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 54.6A.42423.54DC9746; Fri, 2 Jun 2023 12:06:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183~k0tyREed30212702127eucas1p1U; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110645eusmtrp14019d1d594f4a33202fbe00e12e43d12~k0tyQn6No2194821948eusmtrp1Z; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-33-6479cd45188b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 26.A9.10549.54DC9746; Fri, 2 Jun 2023 12:06:45 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230602110645eusmtip23cc9b3b71b8ced0fc78dfa05a342c3a8~k0tyGqxd_1061810618eusmtip2E; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:44 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 2/8] test_sysctl: Fix test metadata getters Date: Fri, 2 Jun 2023 13:06:32 +0200 Message-ID: <20230602110638.789426-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djP87quZytTDK4eU7bYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKeHr9G3PBVqGKu31bmBoY u/m7GDk4JARMJO6csexi5OIQEljBKPH1SDcjhPOFUWLHscvsEM5nRomu2fuAHE6wjrWzG6Gq ljNKrJ31hwmu6vT+r6wQzhZGibZdT1hBWtgEdCTOv7nDDGKLCIhLnDi9GaydWWACo0Tful8s IAlhAWuJOSt7wXawCKhI9HxZzgRi8wrYSOycu5kNYre8RNv16YwgNqeArcSh02fYIGoEJU7O fAI2hxmopnnrbGYIW0Li4IsXzBC9yhIT1v1mhbBrJU5tuQV2toTAAQ6Jv90fmSDB4SIxpSsM okZY4tXxLVA/y0icntzDAlE/mVFi/78P7BDOakaJZY1fmSCqrCVarjyB6nCUOHy8mxliKJ/E jbeCEAfxSUzaNh0qzCvR0SY0gVFlFpIXZiF5YRaSFxYwMq9iFE8tLc5NTy02zEst1ytOzC0u zUvXS87P3cQITBun/x3/tINx7quPeocYmTgYDzFKcDArifAKhZWnCPGmJFZWpRblxxeV5qQW H2KU5mBREufVtj2ZLCSQnliSmp2aWpBaBJNl4uCUamBiW7pqlT+3/NeKf/+frTN+LvGzf1e6 Eff/xyqaG9e6dchEPz77f+l/8xVWj/7bf+SfHb9l5u/8YlHmiVtd1Wp80rdpHnnVp694zrn/ dOuZkA23XLMd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JsK hPMNeJbN9Zm1XG2BzPf84NKgqX1NH9q5G+S8tZdsCFzcnMYm1s7+WvzxeqFrV1rPeWeL3tBf PKPq44ETkgmXDy9teMX8RkpP7zVTQUVojF1I/OvJvw7pLO+5klkdPrE6ddNiXcaNIfvb1m96 qf9yUtDtY1VCRW/XVjlP+njqnfelM3NrVY0cD/z7r3p3Ik/qo1MzVz3MEDRWYinOSDTUYi4q TgQApbbyXDMDAAA= X-CMS-MailID: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 X-Msg-Generator: CA X-RootMTR: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The functions get_test_{count,enabled,target} use awk to get the N'th field in the ALL_TESTS variable. A variable with leading zeros (e.g. 0009) is misinterpreted as an entire line instead of the N'th field. Remove the leading zeros so this does not happen. We can now use the helper in tests 6, 7 and 8. Signed-off-by: Joel Granados --- tools/testing/selftests/sysctl/sysctl.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index bfc54b422f25..cb8f83dfe16b 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -730,7 +730,7 @@ sysctl_test_0005() sysctl_test_0006() { - TARGET="${SYSCTL}/bitmap_0001" + TARGET="${SYSCTL}/$(get_test_target 0006)" reset_vals ORIG="" run_bitmaptest @@ -738,7 +738,7 @@ sysctl_test_0006() sysctl_test_0007() { - TARGET="${SYSCTL}/boot_int" + TARGET="${SYSCTL}/$(get_test_target 0007)" if [ ! -f $TARGET ]; then echo "Skipping test for $TARGET as it is not present ..." return $ksft_skip @@ -778,7 +778,7 @@ sysctl_test_0007() sysctl_test_0008() { - TARGET="${SYSCTL}/match_int" + TARGET="${SYSCTL}/$(get_test_target 0008)" if [ ! -f $TARGET ]; then echo "Skipping test for $TARGET as it is not present ..." return $ksft_skip @@ -857,25 +857,32 @@ function test_num() usage fi } +function remove_leading_zeros() +{ + echo $1 | sed 's/^0*//' +} function get_test_count() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $2}' } function get_test_enabled() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $3}' } function get_test_target() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $4}' }