From nobody Thu Sep 18 01:30:50 2025 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 25B1CC4332F for ; Mon, 12 Dec 2022 22:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbiLLWZk (ORCPT ); Mon, 12 Dec 2022 17:25:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233528AbiLLWZh (ORCPT ); Mon, 12 Dec 2022 17:25:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83C12B7C1 for ; Mon, 12 Dec 2022 14:25:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 02AE861253 for ; Mon, 12 Dec 2022 22:25:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16922C433D2; Mon, 12 Dec 2022 22:25:34 +0000 (UTC) Date: Mon, 12 Dec 2022 17:25:33 -0500 From: Steven Rostedt To: LKML Cc: John 'Warthog9' Hawley Subject: [for-next] ktest.pl: One more change I had in store for 6.2 Message-ID: <20221212172533.184db5e6@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest.git for-next Head SHA1: 88a51b4f2e65ca4378a81ff0925fad076e82e177 Steven Rostedt (Google) (1): ktest.pl: Add shell commands to variables ---- tools/testing/ktest/ktest.pl | 9 ++++++++- tools/testing/ktest/sample.conf | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) --------------------------- commit 88a51b4f2e65ca4378a81ff0925fad076e82e177 Author: Steven Rostedt (Google) Date: Wed Dec 7 21:29:44 2022 -0500 ktest.pl: Add shell commands to variables =20 Allow variables to execute shell commands. Note, these are processed wh= en they are first seen while parsing the config file. This is useful if you have the same config file used for multiple hosts (as they may be in a = git repository). =20 HOSTNAME :=3D ${shell hostname} DEFAULTS IF "${HOSTNAME}" =3D=3D "frodo" =20 Link: https://lkml.kernel.org/r/20221207212944.277ee850@gandalf.local.h= ome =20 Signed-off-by: Steven Rostedt (Google) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 1737c59e4ff6..ac59999ed3de 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -802,7 +802,14 @@ sub process_variables { my $end =3D $3; # append beginning of value to retval $retval =3D "$retval$begin"; - if (defined($variable{$var})) { + if ($var =3D~ s/^shell\s+//) { + $retval =3D `$var`; + if ($?) { + doprint "WARNING: $var returned an error\n"; + } else { + chomp $retval; + } + } elsif (defined($variable{$var})) { $retval =3D "$retval$variable{$var}"; } elsif (defined($remove_undef) && $remove_undef) { # for if statements, any variable that is not defined, diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.c= onf index 5e7d1d729752..2d0fe15a096d 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf @@ -259,6 +259,14 @@ # If PATH is not a config variable, then the ${PATH} in # the MAKE_CMD option will be evaluated by the shell when # the MAKE_CMD option is passed into shell processing. +# +# Shell commands can also be inserted with the ${shell } +# expression. Note, this is case sensitive, thus ${SHELL } +# will not work. +# +# HOSTNAME :=3D ${shell hostname} +# DEFAULTS IF "${HOSTNAME}" =3D=3D "frodo" +# =20 #### Using options in other options #### #