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 C0381C433EF for ; Thu, 2 Dec 2021 21:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348442AbhLBVWv (ORCPT ); Thu, 2 Dec 2021 16:22:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377023AbhLBVV7 (ORCPT ); Thu, 2 Dec 2021 16:21:59 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44F9C061757 for ; Thu, 2 Dec 2021 13:18:36 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so3515630pjc.4 for ; Thu, 02 Dec 2021 13:18:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EBP/wA0riUq0Ehh4ikwK9vvTmgH1MK1/7+RgvBguglo=; b=N2aH43V+EmEkAYBQ4ZU8oiQjZUj0ZtxyuKwGaI0XsO5N0jm3Hds3g9qzxVdaTCCKOg DIpXFOI5A3QvIoQ0lLFtzAivfMxNAJaUOv/+59P3nvJtyQybbxuK7mTZM5Xh71yxRzrA zhEm0+g0xv1BGJOmyXQv54+vOqV8Jhrx40iVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EBP/wA0riUq0Ehh4ikwK9vvTmgH1MK1/7+RgvBguglo=; b=Cannju0luBK1TyRJrYCK65ZdYPN4s9AbQs+ZD4Ip9uhGTTg2KpdPNFWiVhnRPLf3cp VYehbFJwAISjz31bjJNcaxlT8Ey1XacILXnJ5IzIhG1PIRrvWh6HZLHLZFgdazBwKVQL hZhLbkOcA1YY1qvQtPa10Jb7OtSC+QXO62pIdE19gunFo1nTc6KABo9jGapUkSRk7Y3b 8jc9VXenViwMrb2qtBzbc6Hv1sYUpw2fpD0bLczhW4Yr6OEbEXveQyIEv6TN/sR1bxVY OyWfiIoi2pH5AWI8jMuFYkqemqvtUq7OuvJ2jc2fPEIXD4idMgwYOQJcU64RNcoxxSCw hY0A== X-Gm-Message-State: AOAM533vhXoMp2b5EfcQI7CkNmgzktwHSa8iTNH1Cucqx3tYguMU5ruO l/8X93feIy+h1uapkiQad4yUSQ== X-Google-Smtp-Source: ABdhPJy/eTiQgIc3gFRh0X9gTiqG+h8JNywQwRwj9tzI/4pP6ptAyEFgnqcH7Bd2XKPJ9nIag3LPcg== X-Received: by 2002:a17:90b:4a89:: with SMTP id lp9mr8971160pjb.6.1638479916404; Thu, 02 Dec 2021 13:18:36 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o1sm3274138pjs.30.2021.12.02.13.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 13:18:36 -0800 (PST) Date: Thu, 2 Dec 2021 13:18:35 -0800 From: Kees Cook To: Cristian Marussi Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sjpark@amazon.de, shuah@kernel.org Subject: Re: [PATCH] selftests/kselftest/runner.sh: Add optional command parameters in settings Message-ID: <202112021310.E1B3208@keescook> References: <20211202142056.17386-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211202142056.17386-1-cristian.marussi@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 02, 2021 at 02:20:56PM +0000, Cristian Marussi wrote: > Some testcases allow for optional commandline parameters but as of now > there is now way to provide such arguments to the runner script. > > Add support to the per-test-directory "settings" file to provide such > optional arguments; two new optional fields can now be defined in > "settings": > > - args="": general arguments common to all testcase commands in > the test directory > > - _args="": custom arguments specific to only one > specific testcase command > > Signed-off-by: Cristian Marussi > --- > Used to configure the use of a specific rtc device on CI systems with: > tools/testing/selftests/rtc/settings: > timeout=90 > rtctest_args="/dev/rtc1" I like this idea generally, but I have some concern that this is muddling the test's settings ("do not expect me to finish before timeout=90") vs the local system's settings ("here is where to find the rtc to test"). I can't, however, think of a better way to handle this currently. :P Is this case common enough that a given test shouldn't, instead, just take config from environment variables set by the CI? (Also, will we need to worry in the future about running the same test multiple times with different system settings? ("try each of these /dev nodes...") Is there a patch for the changes to the RTC test? > --- > tools/testing/selftests/kselftest/runner.sh | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh > index a9ba782d8ca0..f877a8571927 100644 > --- a/tools/testing/selftests/kselftest/runner.sh > +++ b/tools/testing/selftests/kselftest/runner.sh > @@ -49,6 +49,15 @@ run_one() > > # Reset any "settings"-file variables. > export kselftest_timeout="$kselftest_default_timeout" > + > + # Optional arguments for any command, possibly defined in settings > + # as args="" > + kselftest_args="" > + > + # Optional arguments for this command, possibly defined in settings > + # as <$BASENAME_TEST>_args="" > + kselftest_cmd_args_ref="kselftest_${BASENAME_TEST}_args" > + > # Load per-test-directory kselftest "settings" file. > settings="$BASE_DIR/$DIR/settings" > if [ -r "$settings" ] ; then > @@ -69,7 +78,8 @@ run_one() > echo "# Warning: file $TEST is missing!" > echo "not ok $test_num $TEST_HDR_MSG" > else > - cmd="./$BASENAME_TEST" > + eval kselftest_cmd_args="\$$kselftest_cmd_args_ref" nitpit: Just to avoid tripping any future work to gracefully handle unset variables, maybe this could specify an empty-string default: eval kselftest_cmd_args="\${$kselftest_cmd_args_ref:-}" > + cmd="./$BASENAME_TEST $kselftest_cmd_args $kselftest_args" > if [ ! -x "$TEST" ]; then > echo "# Warning: file $TEST is not executable" > > -- > 2.17.1 > -- Kees Cook