Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2307055rwd; Fri, 16 Jun 2023 02:03:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6aJvfTMBUpDle0Qxyo7rCX4it7dD6lYIge3HKQgtsBXkadWTkgqcN1JHrZg44KrdgPJlVY X-Received: by 2002:a05:6a20:8f28:b0:10e:a8e6:35d1 with SMTP id b40-20020a056a208f2800b0010ea8e635d1mr1682146pzk.40.1686906228072; Fri, 16 Jun 2023 02:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686906228; cv=none; d=google.com; s=arc-20160816; b=r5bUz1bJbeKNGtsayBCnfV9a6AaHVY/fN0PMOM2WrPa/7jmevpCEKxNJkWXcwKxXCM gw4kgH297bLuY3VAkEiFvdj678lVglTRcDpdD+AHbJ6wy5Mr8AZWKxM9PNCEnGfjW7Gx viulfGC//lo5XjlkdzhfWtKLU6H2Mf+oJJEPKFlvPNEjfnhYunm1pU+4x2Bk78t3QIxV Y57dgsPcEdb6RTTVXPOppm1rT8BmTe5kIsolP7TXpCvIKJieQHYV5yd7IEkIWTMkfLCQ ypFt7VfDdno/7ONn2QqIT16eTeoDUY6z2rhdpz60XfXJGkNGSdvdmIQDxYovy87jf/lS 0NYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; b=iTA0+aZP2mgvYQCaP7YQvmM8/MuqRL7OuuLXW1Arf88Nn0udL4fDFsOE+oivfREFQ2 ZbT0ahLnHFOEvs8qc6Q7U1HwayUCxqniTM0ocwKeOGTfrlYrx15HjbdrV7jqtlCLBnXZ 997teEexMB6LLL8gyJttsngw+WabVtGZVSY3oi5b1pAaEaoBjCWmB/q1XKxBLsb4mAR3 4p/cxl6RnHJTz9VckO0e/M3zCwZGIaAjZ3OwYjVsC+TpTcn4bnOfjCDLwdNLYrV/J85x rUZ1F4nEbneYv4cG72nXJIUIThdoVx/zkQvDFKmx68/eEyHVha+McWs+v1AfNykW8+Wf IhGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ELoF/9yU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w185-20020a6262c2000000b0065ee6c40f91si10857155pfb.159.2023.06.16.02.03.36; Fri, 16 Jun 2023 02:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="ELoF/9yU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343770AbjFPI7o (ORCPT + 99 others); Fri, 16 Jun 2023 04:59:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245405AbjFPI7e (ORCPT ); Fri, 16 Jun 2023 04:59:34 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B241BC3 for ; Fri, 16 Jun 2023 01:59:33 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085931euoutp01ba0f5e21ac520b1b6453b80882efa9d6~pGAsQQXto0219502195euoutp01a for ; Fri, 16 Jun 2023 08:59:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085931euoutp01ba0f5e21ac520b1b6453b80882efa9d6~pGAsQQXto0219502195euoutp01a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905971; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ELoF/9yUQ7IjrBkRGfgL1x+5x7nyLwVG0D4iC3JV05CoWun1x1Zw3lyPCyPO0xAGl TKvRMMMOK2TRtYy/I6h8hmBb+E/kYZQf/TFK5qw14NNsxbLOW5jQYUtv7CV6FMNnfM UpjaqRYGf/EMbGCCM55ZsKXbm2xoyLhQmeRo4ZbY= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085931eucas1p2bc2687a34c3ff9d55124f6115568dc59~pGAsI7-gc1069610696eucas1p2m; Fri, 16 Jun 2023 08:59:31 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F6.C4.11320.2742C846; Fri, 16 Jun 2023 09:59:31 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18~pGAr4XYjz0641806418eucas1p2w; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085930eusmtrp12126bbccdb46c5978b271a0fd6a1786f~pGAr3tq6Z0890108901eusmtrp1P; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-38-648c24725a0b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 39.9E.14344.2742C846; Fri, 16 Jun 2023 09:59:30 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230616085930eusmtip1fd95dc136c7c8f4e24f37577e65ff7fb~pGArtLQ4O1526615266eusmtip1O; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:29 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 2/8] test_sysctl: Fix test metadata getters Date: Fri, 16 Jun 2023 10:59:16 +0200 Message-ID: <20230616085922.3066990-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7djPc7rFKj0pBve2MVns2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlPL3+jblgq1DF3b4tTA2M 3fxdjJwcEgImEgt/nmbsYuTiEBJYwShx8mMflPOFUaLj4g9mkCohgc+MEt2nS2A6Zp5/wg4R X84o8a5fAq7m/ZJkiOatjBK32r6zgiTYBHQkzr+5AzZIREBc4sTpzYwgNrPABEaJWYc4QGxh ATuJG08XsIHYLAK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uISJ05vZgSxmQUmMErMOsQBYgsL2EnceLqADcRmEVCV+LbsLTuIzStgK/Fh93NGiG3y Em3Xp4PZnED1jyc1gNUIAdU03u6HqheUODnzCQvEfHmJ5q2zmSFsCYmDL14A2RxAc5QlPj1P gBhZK/H57zPGCYwis5B0z0LSPQtJ9wJG5lWMIqmlxbnpucVGesWJucWleel6yfm5mxiBEbXt 2M8tOxhXvvqod4iRiYPxEKMEB7OSCO+yE10pQrwpiZVVqUX58UWlOanFhxhNgd6cyCwlmpwP jOm8knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamhB2ewembrmfy zoldI/XW9Uz7461qBsZHNzhev7DOZuGK/7mvO3U2Hd3y7+Pzh5r/H0Ser9240tPqEd9vYe4H xfeOp9yQ/MG10Wgfk4PB3dTGaq+y2Sz6loccVbj5rky5+KTf3X7rp6s9B1TY7wsYToj/tPFP QN5uDu3J7EdaE07M6VttOCNd7+cEYTZvLfUaQ6OLRZbHt0vt3uSr+3jdXo1pqz0eGhWJ7Fi/ 2GVu5t/PVwOVjdYcTD/lol1kebrBSUFLJeZFPlNMybtGRjXx3qYnRe4b9zhUv+KakZQupf/t WS5318L/Xd8UTf1X7JjOv85rhrpv+e5tdw74/ZLYfeLY3j28nlqRt57pbBLnVmIpzkg01GIu Kk4EAEl0ieUxAwAA X-CMS-MailID: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 X-Msg-Generator: CA X-RootMTR: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 References: <20230616085922.3066990-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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}' } -- 2.30.2