[2/2] perf test: Set PERF_EXEC_PATH for script execution

Message ID 20230622235357.225190-2-namhyung@kernel.org
State New
Headers
Series [1/2] perf script: Initialize buffer for regs_map() |

Commit Message

Namhyung Kim June 22, 2023, 11:53 p.m. UTC
  The task-analyzer.py script (actually every other scripts too) requires
PERF_EXEC_PATH env to find dependent libraries and scripts. For scripts
test to run correctly, it needs to set PERF_EXEC_PATH to the perf tool
source directory.

Instead of blindly update the env, let's check the directory structure
to make sure it points to the correct location.

Fixes: e8478b84d6ba ("perf test: add new task-analyzer tests")
Cc: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: Aditya Gupta <adityag@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/tests/shell/test_task_analyzer.sh | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Ian Rogers June 23, 2023, 12:17 a.m. UTC | #1
On Thu, Jun 22, 2023 at 4:54 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> The task-analyzer.py script (actually every other scripts too) requires
> PERF_EXEC_PATH env to find dependent libraries and scripts. For scripts
> test to run correctly, it needs to set PERF_EXEC_PATH to the perf tool
> source directory.
>
> Instead of blindly update the env, let's check the directory structure
> to make sure it points to the correct location.
>
> Fixes: e8478b84d6ba ("perf test: add new task-analyzer tests")
> Cc: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
> Cc: Hagen Paul Pfeifer <hagen@jauu.net>
> Cc: Aditya Gupta <adityag@linux.ibm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/shell/test_task_analyzer.sh | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
> index 59785dfc11f8..0095abbe20ca 100755
> --- a/tools/perf/tests/shell/test_task_analyzer.sh
> +++ b/tools/perf/tests/shell/test_task_analyzer.sh
> @@ -5,6 +5,12 @@
>  tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
>  err=0
>
> +# set PERF_EXEC_PATH to find scripts in the source directory
> +perfdir=$(dirname "$0")/../..
> +if [ -e "$perfdir/scripts/python/Perf-Trace-Util" ]; then
> +  export PERF_EXEC_PATH=$perfdir
> +fi
> +
>  cleanup() {
>    rm -f perf.data
>    rm -f perf.data.old
> --
> 2.41.0.162.gfafddb0af9-goog
>
  

Patch

diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
index 59785dfc11f8..0095abbe20ca 100755
--- a/tools/perf/tests/shell/test_task_analyzer.sh
+++ b/tools/perf/tests/shell/test_task_analyzer.sh
@@ -5,6 +5,12 @@ 
 tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
 err=0
 
+# set PERF_EXEC_PATH to find scripts in the source directory
+perfdir=$(dirname "$0")/../..
+if [ -e "$perfdir/scripts/python/Perf-Trace-Util" ]; then
+  export PERF_EXEC_PATH=$perfdir
+fi
+
 cleanup() {
   rm -f perf.data
   rm -f perf.data.old