From patchwork Mon Dec 12 22:25:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 32551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2502254wrr; Mon, 12 Dec 2022 14:33:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5n0UYjm+06gE6uCpXICNr9nLj7+8e5H46pvQC/ouIUxIz0FZ6laEBhjL7c1MIeUgktuVcO X-Received: by 2002:a17:902:8c8d:b0:187:1dcf:dc3 with SMTP id t13-20020a1709028c8d00b001871dcf0dc3mr16999891plo.12.1670884425941; Mon, 12 Dec 2022 14:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670884425; cv=none; d=google.com; s=arc-20160816; b=08zG0r8gyIciIRvZup42FPCnR9kUSL+oKcAg5oC96UXE/Lde71bSH8zHA/1aBjXHQc FBa9HRrGX99YpRwt8g/zQlevH4jfp4NdYQNcB0r6XU9z3I9j9+0IU94Iz06Sy4M9y1eW XgDt6qiUhODS1lC+L7dmBJH75snxsCVvoLe35rlUA/zuqK4mUyfM3AB1KSLExMxsn7bU mFjK/IUJGHw0Ur5UXaN0Acl7EQH0HIJ7+cY6iT9KFpjaE7ecViy/lR8KGdzXCUIxQF1U j9+pdr3JuDT8kLXPCjy7NjHhX4zLfVGpHr5f9cPLc9Oj7FcXc8FRcnUnoHX2RGgg6uri fUkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=OrSYLrQ/Ov5prrQL+cxLuZ5SwW8CwZYd11H856tqpf8=; b=hqqjKKSeWoIDKDGrENBaJfSVWtzXb2peCHhRmukACzEBnuEMLu/IpDmBi5LK7TnCK8 sD8CNwO412hiy5C8wHFOMlFa+zhHlS+WF3sMSNW62C1gle6eNKUbgBu+DE8IiwyuQ2kD MO83irr5683rgdJgG2N2QQWkYBndY5WZsU+pKRMugN4grXRFVOAfOSkNUZbnT5+UYGJw Swayz4Zde/rcmMIC320CwYjnCmwvHde+54slJfHTdUAHy3CjW4pm1a2R/r74liGGcp1q BZF1Ncb+Vh6vXIzHzUiLRA8ealg/QVuan4sdCfT/THvmSW9PZPIFl4Qdr4G+ywf4YxVl aTtw== ARC-Authentication-Results: i=1; mx.google.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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a170902bb8a00b00188bee6e9f4si10034089pls.440.2022.12.12.14.33.31; Mon, 12 Dec 2022 14:33:45 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233730AbiLLWZj (ORCPT + 99 others); Mon, 12 Dec 2022 17:25:39 -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 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752049307605070191?= X-GMAIL-MSGID: =?utf-8?q?1752049307605070191?= 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 Allow variables to execute shell commands. Note, these are processed when 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). HOSTNAME := ${shell hostname} DEFAULTS IF "${HOSTNAME}" == "frodo" Link: https://lkml.kernel.org/r/20221207212944.277ee850@gandalf.local.home 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 = $3; # append beginning of value to retval $retval = "$retval$begin"; - if (defined($variable{$var})) { + if ($var =~ s/^shell\s+//) { + $retval = `$var`; + if ($?) { + doprint "WARNING: $var returned an error\n"; + } else { + chomp $retval; + } + } elsif (defined($variable{$var})) { $retval = "$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.conf 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 := ${shell hostname} +# DEFAULTS IF "${HOSTNAME}" == "frodo" +# #### Using options in other options #### #