Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4883373rdh; Wed, 29 Nov 2023 13:35:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7h5iWV11CSZ0aykXh3DUPHqdn03nStNrt8G39zRnSCLhTqJek6rwGee+vxYh62fVkRw8+ X-Received: by 2002:a05:6a21:7883:b0:187:932f:e249 with SMTP id bf3-20020a056a21788300b00187932fe249mr27220182pzc.4.1701293748262; Wed, 29 Nov 2023 13:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293748; cv=none; d=google.com; s=arc-20160816; b=nJRJ4dow4QqyNPL849aUxV3LTU9reE6bMkyPiI0d65jD+7K3l1nQRBxuAqNqAX5/qn 0EKkI37zxLCph/AL5ZwHySf1kgkVLzrhAccXYv5FFjiL7VySTAgLX8A7/Il5rbEVKxWb ktWRF18V8OUcQJ7YGwVojlSwSV6y3YbTwbjWpiPS/tFI5x0b7/5J7dIlFO4wmsjz5W6F hcY8PZtinFT7yFSn62OymbMRGeK/W06ckNH13eA6CJptPHVEJaPxnChmWAU7dR34jAj1 N5w/mE91xxvimZEL2HuDnVnY3yE07t8cTDbBFnlHZQTbxggN7uORAHhEc8xeRW75M4Fz nN/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=o0vBYr5JM7GPlHuM+wfhHkEVfDthy0I/VW5myloZwv8=; fh=s+iVIXVUBgtmrgM30VqFskabmg0Jfr2GIun8/h4Dwpg=; b=wbGic/kWYEi+Kfu7L6WF6sUygvHWvR29u0MkExi35YQbRk7j+mFdXE5jM8ha+NvKmH QB8ijWF5c/HsLl3nm6WbsYW09wNyHw57rQFrzTPuo6jyhbCsn5AiUTC2y9C6PXPti9n/ esSoW3sUd3i5+kyYa8+xPixg6H+JMTO7oFzjbtZ061w0cgYvImMtq9ypPGeVQVdRDDOb oEceoAb0XlNsqdKYX3DMhmsjvEzaYTx1YiM7aVn7TCSuvrSNTBskKNRjN0h63miLtEcQ gXOr7H7vG0hSEhZ2sc/CzkhUJbQ9PdpFeuO4kNg8unhfEwdCiV7xMDSsQ/i88aFhs0lw i8mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kegeFLM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id cm13-20020a056a020a0d00b00565e0624182si2444481pgb.404.2023.11.29.13.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kegeFLM6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id CC4AF81F358C; Wed, 29 Nov 2023 13:35:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbjK2Vex (ORCPT + 99 others); Wed, 29 Nov 2023 16:34:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234440AbjK2Vev (ORCPT ); Wed, 29 Nov 2023 16:34:51 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0849595 for ; Wed, 29 Nov 2023 13:34:58 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d1b2153ba1so4572177b3.2 for ; Wed, 29 Nov 2023 13:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701293697; x=1701898497; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=o0vBYr5JM7GPlHuM+wfhHkEVfDthy0I/VW5myloZwv8=; b=kegeFLM6hm8HwUxPO/LU0x+VB0Cp2vfgNxzFroEx+HwG89uxGg88vtxvIDe3wUN1aT aXPwxc45UNO2o6zW9gCY7hnqkFUnReL62w839oNTy8IuBILVnFxVNOaEMs5zgQ4zB6xi vIdjIUkMoQwWJkcnEkGjCIdibgtB4qVKRsf9zrnmTNWF6/jvG02HfX7fxKP/FLYIwOhN V4VUFX8TR3Szft76yo7dl20kl2mx5ZpONrEYG+Dm0qI5g7TG4HgNnURYofwl79cBEqzg Auheu2y9H7wC8GKQjM7nYRN6H+NEhFK8VjNavZN2Kg5AqbzczHAcJmEMoOsp/Qs1qwI1 Hfjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701293697; x=1701898497; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o0vBYr5JM7GPlHuM+wfhHkEVfDthy0I/VW5myloZwv8=; b=HWIerJNvDEBjfy4+K6TH8eNteuJQ8frwc/Hmv22k4qVstUMG7EPDak6v7hhFmhzl/u Qhdm9jjJtYZq8+9zVUQg/cB5zfnwd0lc5ATEwYpBKS2KLLkw8LRKtvMkzJqasEpPDFEd b57zCrxg9X3ug3SQ4daGIS47Ie6ZDkd1CiftncK+dajnF7IUsFH5FaqtkqOiSi3FVeYp B3wn7XOFV6/vyosWfBUO8n5gRJJwSjjnQbaqs6MkrXAIrnhRzjiLHrMgvdbl2CZmhaiL QIQ0xrRx4FPvA0VyEN3lX7lstaTzQ9wOr72qxBx1NIfcGUWz4Vp2onmfyG2M06U4rlog 2oaQ== X-Gm-Message-State: AOJu0YwEr3TMDbrswMJ05Mz5WI+j+uIMVDYgQ1C9DVjMJQb7hHEztVlD QwWS5rp1Oj+LkcdrS8fp0/cysYwd37Sx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:763b:80fa:23ca:96f8]) (user=irogers job=sendgmr) by 2002:a05:690c:842:b0:5cc:cd5e:8f0e with SMTP id bz2-20020a05690c084200b005cccd5e8f0emr583925ywb.0.1701293697326; Wed, 29 Nov 2023 13:34:57 -0800 (PST) Date: Wed, 29 Nov 2023 13:34:27 -0800 In-Reply-To: <20231129213428.2227448-1-irogers@google.com> Message-Id: <20231129213428.2227448-3-irogers@google.com> Mime-Version: 1.0 References: <20231129213428.2227448-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v2 3/4] perf test: Use common python setup library From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, James Clark , Athira Rajeev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:35:25 -0800 (PST) Avoid replicated logic by having a common library to set the PYTHON environment variable. Signed-off-by: Ian Rogers --- tools/perf/tests/shell/lib/setup_python.sh | 16 ++++++++++++++++ tools/perf/tests/shell/stat+json_output.sh | 16 +++------------- tools/perf/tests/shell/stat_metrics_values.sh | 14 ++++---------- .../tests/shell/test_perf_data_converter_json.sh | 13 +++---------- 4 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 tools/perf/tests/shell/lib/setup_python.sh diff --git a/tools/perf/tests/shell/lib/setup_python.sh b/tools/perf/tests/shell/lib/setup_python.sh new file mode 100644 index 000000000000..c2fce1793538 --- /dev/null +++ b/tools/perf/tests/shell/lib/setup_python.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +if [ "x$PYTHON" = "x" ] +then + python3 --version >/dev/null 2>&1 && PYTHON=python3 +fi +if [ "x$PYTHON" = "x" ] +then + python --version >/dev/null 2>&1 && PYTHON=python +fi +if [ "x$PYTHON" = "x" ] +then + echo Skipping test, python not detected please set environment variable PYTHON. + exit 2 +fi diff --git a/tools/perf/tests/shell/stat+json_output.sh b/tools/perf/tests/shell/stat+json_output.sh index 196e22672c50..3bc900533a5d 100755 --- a/tools/perf/tests/shell/stat+json_output.sh +++ b/tools/perf/tests/shell/stat+json_output.sh @@ -8,20 +8,10 @@ set -e skip_test=0 +shelldir=$(dirname "$0") +# shellcheck source=lib/setup_python.sh +. "${shelldir}"/lib/setup_python.sh pythonchecker=$(dirname $0)/lib/perf_json_output_lint.py -if [ "x$PYTHON" == "x" ] -then - if which python3 > /dev/null - then - PYTHON=python3 - elif which python > /dev/null - then - PYTHON=python - else - echo Skipping test, python not detected please set environment variable PYTHON. - exit 2 - fi -fi stat_output=$(mktemp /tmp/__perf_test.stat_output.json.XXXXX) diff --git a/tools/perf/tests/shell/stat_metrics_values.sh b/tools/perf/tests/shell/stat_metrics_values.sh index ad94c936de7e..7ca172599aa6 100755 --- a/tools/perf/tests/shell/stat_metrics_values.sh +++ b/tools/perf/tests/shell/stat_metrics_values.sh @@ -1,16 +1,10 @@ #!/bin/bash # perf metrics value validation # SPDX-License-Identifier: GPL-2.0 -if [ "x$PYTHON" == "x" ] -then - if which python3 > /dev/null - then - PYTHON=python3 - else - echo Skipping test, python3 not detected please set environment variable PYTHON. - exit 2 - fi -fi + +shelldir=$(dirname "$0") +# shellcheck source=lib/setup_python.sh +. "${shelldir}"/lib/setup_python.sh grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; } diff --git a/tools/perf/tests/shell/test_perf_data_converter_json.sh b/tools/perf/tests/shell/test_perf_data_converter_json.sh index 6ded58f98f55..c4f1b59d116f 100755 --- a/tools/perf/tests/shell/test_perf_data_converter_json.sh +++ b/tools/perf/tests/shell/test_perf_data_converter_json.sh @@ -6,16 +6,9 @@ set -e err=0 -if [ "$PYTHON" = "" ] ; then - if which python3 > /dev/null ; then - PYTHON=python3 - elif which python > /dev/null ; then - PYTHON=python - else - echo Skipping test, python not detected please set environment variable PYTHON. - exit 2 - fi -fi +shelldir=$(dirname "$0") +# shellcheck source=lib/setup_python.sh +. "${shelldir}"/lib/setup_python.sh perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) result=$(mktemp /tmp/__perf_test.output.json.XXXXX) -- 2.43.0.rc1.413.gea7ed67945-goog