aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/tests/shell/lib/setup_python.sh
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-11-29 13:34:27 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-12-05 15:48:52 -0300
commit8226e4a3b35f525d11934484ee5979399ff8b7dc (patch)
tree28b20ba8efcc3ad96e59d142c257415af955fdf5 /tools/perf/tests/shell/lib/setup_python.sh
parentb809fc656e763296f227b9b31e8f225e5977a8af (diff)
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>
Diffstat (limited to 'tools/perf/tests/shell/lib/setup_python.sh')
-rw-r--r--tools/perf/tests/shell/lib/setup_python.sh16
1 files changed, 16 insertions, 0 deletions
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