Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3712778pxt; Tue, 10 Aug 2021 09:36:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJqfNr3gnxV1kAsVNZkIezJ98GQUD7c9eIvlWgboA2E0re5JDrMpYLCwr/H/OJs0dfzFP1 X-Received: by 2002:a17:906:31cf:: with SMTP id f15mr28968819ejf.272.1628613387481; Tue, 10 Aug 2021 09:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628613387; cv=none; d=google.com; s=arc-20160816; b=tAxLXB6R2TDKy1b5n1sI3JxTW4yPGKmsaVGims5lp8M6BmXon+THh8BMBWmgk6jzCv 5Nj11/9d/8zakPj3u12bGI04QWGctmgHjLFotlDCVvubYfVQFoLTVHGk+vnDpns0VZSd S1BGWovSBepCkeTP8Y8jfwpNC3lqtJrgLhaWg9sRAMTO+8T46/KoRm8bBAJzLDQ/+pmH +8FWPQmq8qR4c9hXU5LXzynwsnbovw2amJ5dDU7X5wtH4/wMpyamuMhyTbzJ9mA1m5Hm wFekJyLvNAoWGCXbeXS9RS8VQWeytH9/jbZpS+TgltBgrV/lTpBciz8k+H3mFQEHsqEq lMUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=69ttibL9r/y/UWLlZYU/dvsb3ho1ANknfZxnaYGPTwI=; b=Bw4h+14/76s2xUBy2HLpKvwjz6lgnLnx5RoveSCUumZnZZB1pOBlJ25R2GYKO2s+Ve TWdQSm2fIB24BjBUUU5nQVReGbMGl8nW5LQu6T2Ufp+OQevKX7IaME+EsGNpjCjNilys l69VcZsxHMfYnUs0ja1lyvHCP2lbn70Nzss1ixYDsNuAFxFwxEp2QYzgwGAPE7fEZwcn YE2BbkdrDtfmtLGCJAWZ6i4Pi6p1fB0uh+iCE9Ip5p0zAhYZiqnoIk2AwH00s53rVa7L 4JU+jM6WbarUBh9ofbzamxqfUuexxLVrW9C/7wkbXgrLg66TzSJogarhHPNrQYC62g6q q49g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CJZ46BLJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si3251184ejz.64.2021.08.10.09.36.02; Tue, 10 Aug 2021 09:36:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CJZ46BLJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240544AbhHJOFb (ORCPT + 99 others); Tue, 10 Aug 2021 10:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbhHJOFa (ORCPT ); Tue, 10 Aug 2021 10:05:30 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD1CC0613D3; Tue, 10 Aug 2021 07:05:08 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id t66so22463310qkb.0; Tue, 10 Aug 2021 07:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=69ttibL9r/y/UWLlZYU/dvsb3ho1ANknfZxnaYGPTwI=; b=CJZ46BLJKnKEPx3cNCoHnWylR/I1OCHvD++LG8z/DMex1/4d+1A5f1CfvcHPy2wK4r R622cmamRDdsO4mGcnQoNAj9Q0LMoMZfgFxZZaWxzI/W90bILN3Y9VVSN4aZx50f4vWg 5aPb1+qHnWx3hCLc4aGngBdN2u8kB/dX1ptZrmDYlTmH6y2nMRePBNv/oG5kq3YU/PNB OfCpTN0Peu5eTutsHPnRi7T7lXqc8B1db5CszlRIJB5VBPmMnGGDdvZqGjaX4bDfe8qB uNKcbOaIlqJy6uUpO0JtHlAjfbURLu40soWgZAo0Mse2SbdGMGBTUggjnj4CQ6CsmxW7 54Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=69ttibL9r/y/UWLlZYU/dvsb3ho1ANknfZxnaYGPTwI=; b=LjINQinXnIAmaMi9CfV3lztg7jkj3Abm9+wOrxxyJSAXlsB4YmhAwIj+d5T78ctqd3 HpohW1g9cytu7eyBgLevLx7qh5CBnCgW6lxiq/Ao3XKNByaK2P4mg6NcNu9BPO5uM38g nlxhxAPXRqApnZHbJBl2Kr/Ig76NvFm/bwk6394iK0migm4fW5gsI0wD1/GQoIgqTBSC m2/hu5ta3rQ+o9T7XYFTd9pEpErbsWKIlbR20K5/I7bP7Xl0gHbihPNxhp6LYKhsuj5e x251BkpP/lWW3bh6SNc+lRW6wjZUqMbqhFgPNEbfdOGVFkzLDQ3BRk6CcDyXSemapGCJ yz5g== X-Gm-Message-State: AOAM531NioVVMwF6mNWD5MbfiR9AG5y+P4m2Ys5NqUoMlhack3eByWFO 5QiGEs72uiN+faxCMCqiBgA= X-Received: by 2002:a05:620a:1998:: with SMTP id bm24mr28464979qkb.171.1628604307930; Tue, 10 Aug 2021 07:05:07 -0700 (PDT) Received: from localhost.localdomain (ec2-35-169-212-159.compute-1.amazonaws.com. [35.169.212.159]) by smtp.gmail.com with ESMTPSA id e6sm4223390qtw.35.2021.08.10.07.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 07:05:07 -0700 (PDT) From: SeongJae Park To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gregkh@linuxfoundation.org, SeongJae Park Subject: [PATCH] selftests/kselftest/runner/run_one(): Allow running non-executable files Date: Tue, 10 Aug 2021 14:04:59 +0000 Message-Id: <20210810140459.23990-1-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park When running a test program, 'run_one()' checks if the program has the execution permission and fails if it doesn't. However, it's easy to mistakenly missing the permission, as some common tools like 'diff' don't support the permission change well[1]. Compared to that, making mistakes in the test program's path would only rare, as those are explicitly listed in 'TEST_PROGS'. Therefore, it might make more sense to resolve the situation on our own and run the program. For the reason, this commit makes the test program runner function to still print the warning message but run the program after giving the execution permission in the case. To make nothing corrupted, it also restores the permission after running it. [1] https://lore.kernel.org/mm-commits/YRJisBs9AunccCD4@kroah.com/ Suggested-by: Greg Kroah-Hartman Signed-off-by: SeongJae Park --- tools/testing/selftests/kselftest/runner.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index cc9c846585f0..2eb31e945709 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -65,15 +65,16 @@ run_one() TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST" echo "# $TEST_HDR_MSG" - if [ ! -x "$TEST" ]; then - echo -n "# Warning: file $TEST is " - if [ ! -e "$TEST" ]; then - echo "missing!" - else - echo "not executable, correct this." - fi + if [ ! -e "$TEST" ]; then + echo "# Warning: file $TEST is missing!" echo "not ok $test_num $TEST_HDR_MSG" else + permission_added="false" + if [ ! -x "$TEST" ]; then + echo "# Warning: file $TEST is not executable" + chmod u+x "$TEST" + permission_added="true" + fi cd `dirname $TEST` > /dev/null ((((( tap_timeout ./$BASENAME_TEST 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | @@ -88,6 +89,9 @@ run_one() else echo "not ok $test_num $TEST_HDR_MSG # exit=$rc" fi) + if [ "$permission_added" = "true" ]; then + chmod u-x "$TEST" + fi cd - >/dev/null fi } -- 2.17.1