Message ID | 20230602013358.900637-6-jhubbard@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp728402vqr; Thu, 1 Jun 2023 18:36:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Rf33u0x/zjrBQbaH/jGVShdoooGfCefLmd1SwFfJWA9qZATgJ0l3wT+4OqN6GiLbFVLme X-Received: by 2002:a17:903:268c:b0:1af:a4f0:bce2 with SMTP id jf12-20020a170903268c00b001afa4f0bce2mr1116734plb.20.1685669794432; Thu, 01 Jun 2023 18:36:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685669794; cv=pass; d=google.com; s=arc-20160816; b=gOahcwZooOpEKnkbvZSTMwqVUUpral/PfEtTugnljTnuNQ9cxU8cpP1IakCibxCe5j AV8Y1JaVt7DbeEh5pZnrEBN+jj832lg7nMfb14LrCAnd9yEAyoSDQcwQHkG7/PXKIXfz r810/erfk0o2y7dLZeD/UmI0+gPAgosf6PyTvVNW1yfHxqHfLH9dTOAotrZG8/HFjS84 9dJlt8zWe0vp7YJpw/hWnN+ih2v4sd/AdOrC9hW96NGQXLne8L25qUCSvG2hdbDQ1TQb hmlAy2XeTjmJoNevevT/m/3iYVsmPs5vus6fxOiqG0lZNwQ1cX2Ki5RUaGVX5aWM/xlG p1oA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YmZVj+Qts14XOWi38dHOr6DxUVKKC0XpuAZpHeEnUuU=; b=HsgqEnZ3IOi0E+AXXiFOFJZWtQYfOvR0Wd5ldEDFucjcuuOt9DsYNrGRGBgPduYdt2 q8Gya4gnB0teV62Lad2t3GYlK2E/xUD2GTfq5ei8ByjaZUvch+/Rs+inekaBvhDtSYlS INWqXdsPdfDPyAdRR1yC+iMMoq7v9BYU3MaDZjy949Tr27xDKn+bw4AUDQEiPgHsS4Ji xlO+UgjVHGxmXE+jXzJmTI4qra7LGHg+IwQBiKap6e7ppVsK9r1Oh/zwr3Kmjnl2ks8O RT385ZWyA0BcS8ip3BSS7R9nDxIIa3ALvDnRv3Apq7MM5UNdcPFq6O7UgNjKRRwm+YIK oSjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=BxpaWauM; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a170902b18500b001ab0c00aec4si9353plr.482.2023.06.01.18.36.20; Thu, 01 Jun 2023 18:36:34 -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=@Nvidia.com header.s=selector2 header.b=BxpaWauM; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233612AbjFBBfM (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Thu, 1 Jun 2023 21:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbjFBBes (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Jun 2023 21:34:48 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2042.outbound.protection.outlook.com [40.107.100.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6369138; Thu, 1 Jun 2023 18:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ckQwf989ZTXULbnQLkaejzyJ1xe2eyF4vKQ0NH8J5Q0TwqUgpmm71FVTr2RYeqawXOx230VzoKBwgHd2Rbxaq+zBJoyJBXmeekW/XSo7GsxqoSgcDDSEXayTjJOkDAre9nD0p7kmUaiYPPB/YXdwB5ieh89iK9zuogQ7Exp/CeE9pHp84BvI1R+osuspZ2wOSCNKb3PvAqpJJCw2zVB5HewdpTWLHtuKCv99aKa79hP4oNoexmNyWewovBiXE3CwXaKsAV103ZB8rcfyFOQafO1zm6att7m5FOYH5/Pk4FEvENMc4fNVAcZVHSPeyQ2B+bqmNK0ZQC+VA+MaWCtNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YmZVj+Qts14XOWi38dHOr6DxUVKKC0XpuAZpHeEnUuU=; b=TgpHZv9L3P2ZyTLmu9DrASCfuPmfax5C0Ry1oM73Rcq3yvB2lVQtH07Dmqr0Sufa1/Y/0ySYZC71HJKNuy4O0p/0opOjrvCmMgCM3LNoiBwNR7lVmEbTdnh4Y5etGYR1K+pfSoaxnUcNp0JM1OXdDaSBrQZTuUqNpyjP5HdLhb1rESACKO0vRpA4IXrKZ0kVkfKS5nsXY5gWRvC8On7XEYKtWI/X9Aeb/0rPiBBZlyozdcypjuZy/sgvcLTHaradJdnDlfzcBGc22yJUtG1L5FadBmXnseWZUi8kksIDaQOYFq1dhUvTeaN78TmequynLYRcftxPCLtyYw1pJBqR6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YmZVj+Qts14XOWi38dHOr6DxUVKKC0XpuAZpHeEnUuU=; b=BxpaWauMkLCRmZ6NFWCyoKBJ7+WhzlOlFB8MBPh29vo7MX2bM7YBaGKSCskcyl3PtF38jUA21HMBypT953lC8+QRVWCtVg6W8kQ4Np6dIY/9Gi9rstyVjKLwX3UtQMpN44Ba+j2ykld+ZawVd6DTqKJKs8xQSk5aLdmcvZ8jJaNKbKjGnxR6RfUdVidzBANr0AZ6Moigv5aiq38Zo+LHqD4xjplBnCLjpvuDvP8VioRVEA1AC1NWZPIwAaeOpEkzkp2090T8iHR/DFDG4TY8t1l4q5LezusWJHAyshn0aA0+tHVhN3ZqHxV/twla4PrmWqyU8iKQFM4AqwYoS0tOAQ== Received: from MW2PR16CA0025.namprd16.prod.outlook.com (2603:10b6:907::38) by SJ0PR12MB5676.namprd12.prod.outlook.com (2603:10b6:a03:42e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Fri, 2 Jun 2023 01:34:39 +0000 Received: from CO1NAM11FT077.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::9e) by MW2PR16CA0025.outlook.office365.com (2603:10b6:907::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Fri, 2 Jun 2023 01:34:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT077.mail.protection.outlook.com (10.13.175.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Fri, 2 Jun 2023 01:34:38 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 18:34:22 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 18:34:21 -0700 Received: from blueforge.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 18:34:21 -0700 From: John Hubbard <jhubbard@nvidia.com> To: Andrew Morton <akpm@linux-foundation.org> CC: David Hildenbrand <david@redhat.com>, Peter Xu <peterx@redhat.com>, "Shuah Khan" <shuah@kernel.org>, Nathan Chancellor <nathan@kernel.org>, <linux-mm@kvack.org>, <linux-kselftest@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, John Hubbard <jhubbard@nvidia.com> Subject: [PATCH 05/12] selftests/mm: fix invocation of tests that are run via shell scripts Date: Thu, 1 Jun 2023 18:33:51 -0700 Message-ID: <20230602013358.900637-6-jhubbard@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230602013358.900637-1-jhubbard@nvidia.com> References: <20230602013358.900637-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT077:EE_|SJ0PR12MB5676:EE_ X-MS-Office365-Filtering-Correlation-Id: ce607a4d-b166-4e9d-c651-08db630987ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NGJ15Pz/mXq4MJhGU7HflwVMbrnMxxr3k1ykK+v2cpE+VNDtqFmcqqS8C8AXv/n2eK9g65330YRHdnwVK+qujcIYzfwb2EGgUGeMJWR3o+qxWv/s92Gg2NieiLYXuIIJks9bzQXGWo8w6jrXQa2aWWMQUYYjT7iJRhJI+32n57fVNdqOKF7fHvqwLaMUZKZ+zvlI/FWlFEYhNDuG0smBsRJhxklxW4Mx2tJdebo0yffOdtmE6iwW0dWlWH6amIlcyI5aplvPvLoxQRFipMyuXn/6BSAjog6z2iSeIRKMC1P1SR8HieNShOG+GsuQIVO5IsNrz0Am/Xt4lnU6BVgHRdtTp/yksoKu+xSBqWGwO1Je+9jp924uZz/gBb5RKLwURQsWxvfb3ctxXn3tOUnwo++tgKx9Qz++heERH/HV10loK8I1mIGH1zCXb84z6PP6Tbebo5DtUQJUSeBYlq+VTGtGzHKTSNQ0bHY8WrmlJpGMW6+3kuCw26SjcIh2U39eRLghXMqaddqcVhB6HPIhENIQ3u1noY0OyZHWvZG880JsEjmek4xfyqianMl9homdny5TR0G6aIlzUxB/pMUSlIRLBQFdYsNc5TZ+EqtqnxRTd5EWtWqYN/FX1rpHhdcfjstwEGcJzdMCwnlhtZJiaBZSO/0DLF3xUQP7ewbBKqgEyViIS2bL2hOknIRSbMgdX0QBGX1jjnfe/wQlG9vTNkvRQHGglOkxtHF6mYRZ7MbalndxiIHxTfSHA4hSsivC X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(40470700004)(36840700001)(46966006)(336012)(426003)(2616005)(83380400001)(36860700001)(26005)(2906002)(8936002)(47076005)(40460700003)(186003)(107886003)(8676002)(40480700001)(82310400005)(478600001)(4326008)(41300700001)(6916009)(356005)(7636003)(70586007)(70206006)(6666004)(316002)(82740400003)(1076003)(36756003)(5660300002)(86362001)(54906003)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 01:34:38.3531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce607a4d-b166-4e9d-c651-08db630987ab X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT077.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5676 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767552890287872036?= X-GMAIL-MSGID: =?utf-8?q?1767552890287872036?= |
Series |
A minor flurry of selftest/mm fixes
|
|
Commit Message
John Hubbard
June 2, 2023, 1:33 a.m. UTC
We cannot depend upon git to reliably retain the executable bit on shell
scripts, or so I was told several years ago while working on this same
run_vmtests.sh script. And sure enough, things such as test_hmm.sh are
lately failing to run, due to lacking execute permissions.
A nice clean way to fix this would have been to use TEST_PROGS instead
of TEST_FILES for the .sh scripts here. That tells the selftest
framework to run these (and emit a warning if the files are not
executable, but still run them anyway).
Unfortunately, run_vmtests.sh has its own run_test() routine, which does
*not* do the right thing for shell scripts.
Fix this by explicitly adding "bash" to each of the shell script
invocations. Leave fixing the overall approach to another day.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
tools/testing/selftests/mm/run_vmtests.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 02.06.23 03:33, John Hubbard wrote: > We cannot depend upon git to reliably retain the executable bit on shell > scripts, or so I was told several years ago while working on this same > run_vmtests.sh script. And sure enough, things such as test_hmm.sh are > lately failing to run, due to lacking execute permissions. > > A nice clean way to fix this would have been to use TEST_PROGS instead > of TEST_FILES for the .sh scripts here. That tells the selftest > framework to run these (and emit a warning if the files are not > executable, but still run them anyway). > > Unfortunately, run_vmtests.sh has its own run_test() routine, which does > *not* do the right thing for shell scripts. > > Fix this by explicitly adding "bash" to each of the shell script > invocations. Leave fixing the overall approach to another day. > > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > --- > tools/testing/selftests/mm/run_vmtests.sh | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh > index 4893eb60d96d..8f81432e4bac 100644 > --- a/tools/testing/selftests/mm/run_vmtests.sh > +++ b/tools/testing/selftests/mm/run_vmtests.sh > @@ -242,18 +242,18 @@ if [ $VADDR64 -ne 0 ]; then > if [ "$ARCH" == "$ARCH_ARM64" ]; then > echo 6 > /proc/sys/vm/nr_hugepages > fi > - CATEGORY="hugevm" run_test ./va_high_addr_switch.sh > + CATEGORY="hugevm" run_test bash ./va_high_addr_switch.sh > if [ "$ARCH" == "$ARCH_ARM64" ]; then > echo $prev_nr_hugepages > /proc/sys/vm/nr_hugepages > fi > fi # VADDR64 > > # vmalloc stability smoke test > -CATEGORY="vmalloc" run_test ./test_vmalloc.sh smoke > +CATEGORY="vmalloc" run_test bash ./test_vmalloc.sh smoke > > CATEGORY="mremap" run_test ./mremap_dontunmap > > -CATEGORY="hmm" run_test ./test_hmm.sh smoke > +CATEGORY="hmm" run_test bash ./test_hmm.sh smoke > > # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests > CATEGORY="madv_populate" run_test ./madv_populate Sounds hacky, but if it gets the job done Acked-by: David Hildenbrand <david@redhat.com>
On Thu, Jun 01, 2023 at 06:33:51PM -0700, John Hubbard wrote: > We cannot depend upon git to reliably retain the executable bit on shell > scripts, or so I was told several years ago while working on this same > run_vmtests.sh script. And sure enough, things such as test_hmm.sh are > lately failing to run, due to lacking execute permissions. > > A nice clean way to fix this would have been to use TEST_PROGS instead > of TEST_FILES for the .sh scripts here. That tells the selftest > framework to run these (and emit a warning if the files are not > executable, but still run them anyway). > > Unfortunately, run_vmtests.sh has its own run_test() routine, which does > *not* do the right thing for shell scripts. > > Fix this by explicitly adding "bash" to each of the shell script > invocations. Leave fixing the overall approach to another day. Is it possible someone just doesn't have "bash" at all? I used to only use "sh" without bash installed I think, but that was not on Linux, so I'm not sure how much that applies.. Maybe use $(SHELL)? I saw a bunch of usage in the tree too.
On 6/2/23 08:34, Peter Xu wrote: > On Thu, Jun 01, 2023 at 06:33:51PM -0700, John Hubbard wrote: >> We cannot depend upon git to reliably retain the executable bit on shell >> scripts, or so I was told several years ago while working on this same >> run_vmtests.sh script. And sure enough, things such as test_hmm.sh are >> lately failing to run, due to lacking execute permissions. >> >> A nice clean way to fix this would have been to use TEST_PROGS instead >> of TEST_FILES for the .sh scripts here. That tells the selftest >> framework to run these (and emit a warning if the files are not >> executable, but still run them anyway). >> >> Unfortunately, run_vmtests.sh has its own run_test() routine, which does >> *not* do the right thing for shell scripts. >> >> Fix this by explicitly adding "bash" to each of the shell script >> invocations. Leave fixing the overall approach to another day. > > Is it possible someone just doesn't have "bash" at all? I used to only use Well, maybe [1]. But that someone won't be running these tests as-is, because the tests explicitly require bash, even before this patch. > "sh" without bash installed I think, but that was not on Linux, so I'm not > sure how much that applies.. sh invocations are for when you want to express that this script should avoid using bash-specific things, in order to ensure portability to other environments. But here, the run_vmtests.sh file requires bash already, as per the first line: #!/bin/bash ...which is ultimately why I decided to use bash, rather than sh here. > > Maybe use $(SHELL)? I saw a bunch of usage in the tree too. > That's more of a Makefile construct that you are seeing, and only in a few odd Makefiles. Recall that in Make, $(SHELL) has the same effect that ${SHELL} has in bash/sh, by the way: dereferencing a variable. And Make's "$(shell ...)" command is what is normally used to *run* a shell command, in the kernel's build system. Having said all that, I will take a quick look at what it would take to shift over to the selftest framework's run_test() instead, in order to avoid this ugly "fix". [1] https://www.bleepingcomputer.com/news/linux/kali-linux-20204-switches-the-default-shell-from-bash-to-zsh/ thanks,
On 6/2/23 03:05, David Hildenbrand wrote: > On 02.06.23 03:33, John Hubbard wrote: >> We cannot depend upon git to reliably retain the executable bit on shell >> scripts, or so I was told several years ago while working on this same >> run_vmtests.sh script. And sure enough, things such as test_hmm.sh are >> lately failing to run, due to lacking execute permissions. >> >> A nice clean way to fix this would have been to use TEST_PROGS instead >> of TEST_FILES for the .sh scripts here. That tells the selftest >> framework to run these (and emit a warning if the files are not >> executable, but still run them anyway). Actually, for the record (and I'll update this in v2), the above is inaccurate, because run_vmtests.sh aspires to be the only TEST_PROGS item here. And I see that the framework does already work if-and-only-if invoked via Make, as in "make run_tests". However, a) Many people naturally expect to run test scripts without (unnecessarily!) involving Make, and b) Based on some experience in building and using various test frameworks over many years, I'd claim that it's better to use shell scripts to collect and manage tests and test scripts, rather than involving Make. Make is a limited, specialized language and is better at handling builds and dependencies. So the "make run_tests" is a convenience, but it should not be the only way to launch a test run. So we still want to fix this up. >> >> Unfortunately, run_vmtests.sh has its own run_test() routine, which does >> *not* do the right thing for shell scripts. >> >> Fix this by explicitly adding "bash" to each of the shell script >> invocations. Leave fixing the overall approach to another day. >> >> Signed-off-by: John Hubbard <jhubbard@nvidia.com> >> --- >> tools/testing/selftests/mm/run_vmtests.sh | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh >> index 4893eb60d96d..8f81432e4bac 100644 >> --- a/tools/testing/selftests/mm/run_vmtests.sh >> +++ b/tools/testing/selftests/mm/run_vmtests.sh >> @@ -242,18 +242,18 @@ if [ $VADDR64 -ne 0 ]; then >> if [ "$ARCH" == "$ARCH_ARM64" ]; then >> echo 6 > /proc/sys/vm/nr_hugepages >> fi >> - CATEGORY="hugevm" run_test ./va_high_addr_switch.sh >> + CATEGORY="hugevm" run_test bash ./va_high_addr_switch.sh >> if [ "$ARCH" == "$ARCH_ARM64" ]; then >> echo $prev_nr_hugepages > /proc/sys/vm/nr_hugepages >> fi >> fi # VADDR64 >> # vmalloc stability smoke test >> -CATEGORY="vmalloc" run_test ./test_vmalloc.sh smoke >> +CATEGORY="vmalloc" run_test bash ./test_vmalloc.sh smoke >> CATEGORY="mremap" run_test ./mremap_dontunmap >> -CATEGORY="hmm" run_test ./test_hmm.sh smoke >> +CATEGORY="hmm" run_test bash ./test_hmm.sh smoke >> # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests >> CATEGORY="madv_populate" run_test ./madv_populate > > Sounds hacky, but if it gets the job done > Yes. It's also hacky that we can't just invoke shell scripts like normal programs. This limitation hurts my sense of "things should be more perfect!". :) > Acked-by: David Hildenbrand <david@redhat.com> > Thanks for the ack.
On Fri, Jun 02, 2023 at 12:19:17PM -0700, John Hubbard wrote: > On 6/2/23 08:34, Peter Xu wrote: > > On Thu, Jun 01, 2023 at 06:33:51PM -0700, John Hubbard wrote: > > > We cannot depend upon git to reliably retain the executable bit on shell > > > scripts, or so I was told several years ago while working on this same > > > run_vmtests.sh script. And sure enough, things such as test_hmm.sh are > > > lately failing to run, due to lacking execute permissions. > > > > > > A nice clean way to fix this would have been to use TEST_PROGS instead > > > of TEST_FILES for the .sh scripts here. That tells the selftest > > > framework to run these (and emit a warning if the files are not > > > executable, but still run them anyway). > > > > > > Unfortunately, run_vmtests.sh has its own run_test() routine, which does > > > *not* do the right thing for shell scripts. > > > > > > Fix this by explicitly adding "bash" to each of the shell script > > > invocations. Leave fixing the overall approach to another day. > > > > Is it possible someone just doesn't have "bash" at all? I used to only use > > Well, maybe [1]. But that someone won't be running these tests as-is, because > the tests explicitly require bash, even before this patch. > > > "sh" without bash installed I think, but that was not on Linux, so I'm not > > sure how much that applies.. > > sh invocations are for when you want to express that this script should > avoid using bash-specific things, in order to ensure portability to > other environments. > > But here, the run_vmtests.sh file requires bash already, as per the > first line: > > #!/bin/bash > > ...which is ultimately why I decided to use bash, rather than sh here. That one can be easily override with $XXX run_vmtests.sh, hard-coded "bash" in Makefiles can't, afaiu. > > > > > Maybe use $(SHELL)? I saw a bunch of usage in the tree too. > > > > That's more of a Makefile construct that you are seeing, and only in a > few odd Makefiles. Recall that in Make, $(SHELL) has the same effect > that ${SHELL} has in bash/sh, by the way: dereferencing a variable. > > And Make's "$(shell ...)" command is what is normally used to *run* a > shell command, in the kernel's build system. > > Having said all that, I will take a quick look at what it would take > to shift over to the selftest framework's run_test() instead, in > order to avoid this ugly "fix". Just to mention that I was not talking about $(shell ...), but the environment var $(SHELL), or "env | grep SHELL". Please feel free to have a look at tools/perf/arch/x86/Makefile. Thanks,
On 6/2/23 14:36, Peter Xu wrote: ... >> But here, the run_vmtests.sh file requires bash already, as per the >> first line: >> >> #!/bin/bash >> >> ...which is ultimately why I decided to use bash, rather than sh here. > > That one can be easily override with $XXX run_vmtests.sh, hard-coded "bash" > in Makefiles can't, afaiu. Yes, but then you'd have to deal with the rest of the kernel, and bash is just completely woven into the whole thing. Just in the selftests alone, there are dozens or hundreds of direct invocations. $ git grep -w bash | wc -l 1146 $ cd tools/testing/selftests/ $ git grep -w bash | wc -l 560 $ git grep -w bash | grep -v '/bin' | wc -l 113 That ship really has sailed: it's not practical to expect that kind of portability here. ... > Just to mention that I was not talking about $(shell ...), but the > environment var $(SHELL), or "env | grep SHELL". > > Please feel free to have a look at tools/perf/arch/x86/Makefile. Yes, but that is a *Makefile*. (And only one out of 145, the others do not use this.) There is no use of SHELL outside of Makefiles, nor in fact anywhere in the kernel. thanks,
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 4893eb60d96d..8f81432e4bac 100644 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -242,18 +242,18 @@ if [ $VADDR64 -ne 0 ]; then if [ "$ARCH" == "$ARCH_ARM64" ]; then echo 6 > /proc/sys/vm/nr_hugepages fi - CATEGORY="hugevm" run_test ./va_high_addr_switch.sh + CATEGORY="hugevm" run_test bash ./va_high_addr_switch.sh if [ "$ARCH" == "$ARCH_ARM64" ]; then echo $prev_nr_hugepages > /proc/sys/vm/nr_hugepages fi fi # VADDR64 # vmalloc stability smoke test -CATEGORY="vmalloc" run_test ./test_vmalloc.sh smoke +CATEGORY="vmalloc" run_test bash ./test_vmalloc.sh smoke CATEGORY="mremap" run_test ./mremap_dontunmap -CATEGORY="hmm" run_test ./test_hmm.sh smoke +CATEGORY="hmm" run_test bash ./test_hmm.sh smoke # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests CATEGORY="madv_populate" run_test ./madv_populate