1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4if [ "x$PYTHON" = "x" ] 5then 6 python3 --version >/dev/null 2>&1 && PYTHON=python3 7fi 8if [ "x$PYTHON" = "x" ] 9then 10 python --version >/dev/null 2>&1 && PYTHON=python 11fi 12if [ "x$PYTHON" = "x" ] 13then 14 echo Skipping test, python not detected please set environment variable PYTHON. 15 exit 2 16fi 17 18# Set PYTHONPATH to find the in-tree built perf.so first, avoiding system-wide perf.so 19if [ -n "$PERF_EXEC_PATH" ] && [ -d "$PERF_EXEC_PATH/python" ]; then 20 PYTHONPATH_DIR="$PERF_EXEC_PATH/python" 21elif [ -d "$(dirname "$0")/../../python" ]; then 22 PYTHONPATH_DIR="$(dirname "$0")/../../python" 23elif [ -d "$(dirname "$0")/../python" ]; then 24 PYTHONPATH_DIR="$(dirname "$0")/../python" 25fi 26 27if [ -n "$PYTHONPATH_DIR" ]; then 28 export PYTHONPATH="$PYTHONPATH_DIR${PYTHONPATH:+:$PYTHONPATH}" 29fi 30