Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Use common python setup library

Avoid replicated logic by having a common library to set the PYTHON
environment variable.

Reviewed-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231129213428.2227448-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
8226e4a3 b809fc65

+26 -33
+16
tools/perf/tests/shell/lib/setup_python.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + if [ "x$PYTHON" = "x" ] 5 + then 6 + python3 --version >/dev/null 2>&1 && PYTHON=python3 7 + fi 8 + if [ "x$PYTHON" = "x" ] 9 + then 10 + python --version >/dev/null 2>&1 && PYTHON=python 11 + fi 12 + if [ "x$PYTHON" = "x" ] 13 + then 14 + echo Skipping test, python not detected please set environment variable PYTHON. 15 + exit 2 16 + fi
+3 -13
tools/perf/tests/shell/stat+json_output.sh
··· 8 8 9 9 skip_test=0 10 10 11 + shelldir=$(dirname "$0") 12 + # shellcheck source=lib/setup_python.sh 13 + . "${shelldir}"/lib/setup_python.sh 11 14 pythonchecker=$(dirname $0)/lib/perf_json_output_lint.py 12 - if [ "x$PYTHON" == "x" ] 13 - then 14 - if which python3 > /dev/null 15 - then 16 - PYTHON=python3 17 - elif which python > /dev/null 18 - then 19 - PYTHON=python 20 - else 21 - echo Skipping test, python not detected please set environment variable PYTHON. 22 - exit 2 23 - fi 24 - fi 25 15 26 16 stat_output=$(mktemp /tmp/__perf_test.stat_output.json.XXXXX) 27 17
+4 -10
tools/perf/tests/shell/stat_metrics_values.sh
··· 1 1 #!/bin/bash 2 2 # perf metrics value validation 3 3 # SPDX-License-Identifier: GPL-2.0 4 - if [ "x$PYTHON" == "x" ] 5 - then 6 - if which python3 > /dev/null 7 - then 8 - PYTHON=python3 9 - else 10 - echo Skipping test, python3 not detected please set environment variable PYTHON. 11 - exit 2 12 - fi 13 - fi 4 + 5 + shelldir=$(dirname "$0") 6 + # shellcheck source=lib/setup_python.sh 7 + . "${shelldir}"/lib/setup_python.sh 14 8 15 9 grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; } 16 10
+3 -10
tools/perf/tests/shell/test_perf_data_converter_json.sh
··· 6 6 7 7 err=0 8 8 9 - if [ "$PYTHON" = "" ] ; then 10 - if which python3 > /dev/null ; then 11 - PYTHON=python3 12 - elif which python > /dev/null ; then 13 - PYTHON=python 14 - else 15 - echo Skipping test, python not detected please set environment variable PYTHON. 16 - exit 2 17 - fi 18 - fi 9 + shelldir=$(dirname "$0") 10 + # shellcheck source=lib/setup_python.sh 11 + . "${shelldir}"/lib/setup_python.sh 19 12 20 13 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) 21 14 result=$(mktemp /tmp/__perf_test.output.json.XXXXX)