mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 13:23:23 +01:00
The 'import perf' test needs to set up a path to the python module as well as to know the python command to invoke. These are hard coded at build time to be build a directory and the python used in the build, which is less than desirable. Avoid the hard coded values by reusing the existing shell script python setup and determine a potential built python module via the path of the perf executable. Signed-off-by: Ian Rogers <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Collin Funk <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
37 lines
596 B
Bash
Executable File
37 lines
596 B
Bash
Executable File
#!/bin/bash
|
|
# 'import perf' in python
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Just test if we can load the python binding.
|
|
set -e
|
|
|
|
shelldir=$(dirname "$0")
|
|
# shellcheck source=lib/setup_python.sh
|
|
. "${shelldir}"/lib/setup_python.sh
|
|
|
|
MODULE_DIR=$(dirname "$(which perf)")/python
|
|
|
|
if [ -d "$MODULE_DIR" ]
|
|
then
|
|
CMD=$(cat <<EOF
|
|
import sys
|
|
sys.path.insert(0, '$MODULE_DIR')
|
|
import perf
|
|
print('success!')
|
|
EOF
|
|
)
|
|
else
|
|
CMD=$(cat <<EOF
|
|
import perf
|
|
print('success!')
|
|
EOF
|
|
)
|
|
fi
|
|
|
|
echo -e "Testing 'import perf' with:\n$CMD"
|
|
|
|
if ! echo "$CMD" | $PYTHON | grep -q "success!"
|
|
then
|
|
exit 1
|
|
fi
|
|
exit 0
|