[PATCH v1 06/13] perf test test_task_analyzer: Isolate in temporary directory and make non-exclusive
From: Ian Rogers
Date: Thu Sep 17 2026 - 02:44:38 EST
test_task_analyzer.sh writes perf.data and temporary files directly into
the current working directory, causing collisions when running tests in
parallel.
As a temporary measure until `perf script report` supports an input file
option, resolve perfdir to an absolute path, change directory into $tmpdir
for the test duration, and clean up in the exit trap. Remove the
(exclusive) tag so the test runs in parallel.
perfdir is derived from $0, which may be relative, so it has to be
resolved before the cd into $tmpdir, otherwise both PERF_EXEC_PATH and
the cleanup trap point at paths that no longer exist.
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/tests/shell/test_task_analyzer.sh | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
index 0314412e63b4..6f729d9508f8 100755
--- a/tools/perf/tests/shell/test_task_analyzer.sh
+++ b/tools/perf/tests/shell/test_task_analyzer.sh
@@ -1,8 +1,13 @@
#!/bin/bash
-# perf script task-analyzer tests (exclusive)
+# perf script task-analyzer tests
# SPDX-License-Identifier: GPL-2.0
+# Resolve the source directory before changing the working directory below,
+# $0 may be a relative path and would no longer resolve from $tmpdir.
+perfdir=$(cd "$(dirname "$0")/../.." && pwd)
+
tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
+cd "$tmpdir" || exit 1
# TODO: perf script report only supports input from the CWD perf.data file, make
# it support input from any file.
perfdata="perf.data"
@@ -11,7 +16,6 @@ csvsummary="$tmpdir/csvsummary"
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
@@ -20,8 +24,7 @@ fi
export ASAN_OPTIONS=detect_leaks=0
cleanup() {
- rm -f "${perfdata}"
- rm -f "${perfdata}".old
+ cd "$perfdir" || cd /tmp || exit
rm -rf "$tmpdir"
trap - exit term int
--
2.55.0.1082.g2b9226bbc0-goog