* [PATCH v1] perf tests task-analyzer: Write all test files to tmpdir
@ 2026-03-21 6:16 Ian Rogers
2026-03-26 22:37 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2026-03-21 6:16 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, linux-perf-users, linux-kernel
Writing to the test output files in the current working directory can
fail in various contexts such as continual test. Other tests write to
a mktemp-ed file, make the "perf script task-analyszer tests" follow
this convention too. Currently this isn't possible for the perf.data
file due to a lack of perf script support.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/test_task_analyzer.sh | 37 +++++++++++---------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
index e194fcf61df3..cc74b03477fe 100755
--- a/tools/perf/tests/shell/test_task_analyzer.sh
+++ b/tools/perf/tests/shell/test_task_analyzer.sh
@@ -3,6 +3,10 @@
# SPDX-License-Identifier: GPL-2.0
tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
+# perf script report only supports input from the perf.data file.
+perfdata="perf.data"
+csv="$tmpdir/csv"
+csvsummary="$tmpdir/csvsummary"
err=0
# set PERF_EXEC_PATH to find scripts in the source directory
@@ -15,11 +19,10 @@ fi
export ASAN_OPTIONS=detect_leaks=0
cleanup() {
- rm -f perf.data
- rm -f perf.data.old
- rm -f csv
- rm -f csvsummary
+ rm -f "${perfdata}"
+ rm -f "${perfdata}".old
rm -rf "$tmpdir"
+
trap - exit term int
}
@@ -61,7 +64,7 @@ skip_no_probe_record_support() {
prepare_perf_data() {
# 1s should be sufficient to catch at least some switches
- perf record -e sched:sched_switch -a -- sleep 1 > /dev/null 2>&1
+ perf record -e sched:sched_switch -a -o "${perfdata}" -- sleep 1 > /dev/null 2>&1
# check if perf data file got created in above step.
if [ ! -e "perf.data" ]; then
printf "FAIL: perf record failed to create \"perf.data\" \n"
@@ -130,28 +133,28 @@ test_extended_times_summary_ns() {
}
test_csv() {
- perf script report task-analyzer --csv csv > /dev/null
- check_exec_0 "perf script report task-analyzer --csv csv"
- find_str_or_fail "Comm;" csv "${FUNCNAME[0]}"
+ perf script report task-analyzer --csv "${csv}" > /dev/null
+ check_exec_0 "perf script report task-analyzer --csv ${csv}"
+ find_str_or_fail "Comm;" "${csv}" "${FUNCNAME[0]}"
}
test_csv_extended_times() {
- perf script report task-analyzer --csv csv --extended-times > /dev/null
- check_exec_0 "perf script report task-analyzer --csv csv --extended-times"
- find_str_or_fail "Out-Out;" csv "${FUNCNAME[0]}"
+ perf script report task-analyzer --csv "${csv}" --extended-times > /dev/null
+ check_exec_0 "perf script report task-analyzer --csv ${csv} --extended-times"
+ find_str_or_fail "Out-Out;" "${csv}" "${FUNCNAME[0]}"
}
test_csvsummary() {
- perf script report task-analyzer --csv-summary csvsummary > /dev/null
- check_exec_0 "perf script report task-analyzer --csv-summary csvsummary"
- find_str_or_fail "Comm;" csvsummary "${FUNCNAME[0]}"
+ perf script report task-analyzer --csv-summary "${csvsummary}" > /dev/null
+ check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary}"
+ find_str_or_fail "Comm;" "${csvsummary}" "${FUNCNAME[0]}"
}
test_csvsummary_extended() {
- perf script report task-analyzer --csv-summary csvsummary --summary-extended \
+ perf script report task-analyzer --csv-summary "${csvsummary}" --summary-extended \
>/dev/null
- check_exec_0 "perf script report task-analyzer --csv-summary csvsummary --summary-extended"
- find_str_or_fail "Out-Out;" csvsummary "${FUNCNAME[0]}"
+ check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary} --summary-extended"
+ find_str_or_fail "Out-Out;" "${csvsummary}" "${FUNCNAME[0]}"
}
skip_no_probe_record_support
--
2.53.0.959.g497ff81fa9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf tests task-analyzer: Write all test files to tmpdir
2026-03-21 6:16 [PATCH v1] perf tests task-analyzer: Write all test files to tmpdir Ian Rogers
@ 2026-03-26 22:37 ` Namhyung Kim
2026-03-26 23:17 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2026-03-26 22:37 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, James Clark,
linux-perf-users, linux-kernel
On Fri, Mar 20, 2026 at 11:16:24PM -0700, Ian Rogers wrote:
> Writing to the test output files in the current working directory can
> fail in various contexts such as continual test. Other tests write to
> a mktemp-ed file, make the "perf script task-analyszer tests" follow
> this convention too. Currently this isn't possible for the perf.data
> file due to a lack of perf script support.
I don't know what you mean by the last sentence.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/tests/shell/test_task_analyzer.sh | 37 +++++++++++---------
> 1 file changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
> index e194fcf61df3..cc74b03477fe 100755
> --- a/tools/perf/tests/shell/test_task_analyzer.sh
> +++ b/tools/perf/tests/shell/test_task_analyzer.sh
> @@ -3,6 +3,10 @@
> # SPDX-License-Identifier: GPL-2.0
>
> tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
> +# perf script report only supports input from the perf.data file.
> +perfdata="perf.data"
I thought you want to use a different file name. What's the point of
adding a variable here?
> +csv="$tmpdir/csv"
> +csvsummary="$tmpdir/csvsummary"
> err=0
>
> # set PERF_EXEC_PATH to find scripts in the source directory
> @@ -15,11 +19,10 @@ fi
> export ASAN_OPTIONS=detect_leaks=0
>
> cleanup() {
> - rm -f perf.data
> - rm -f perf.data.old
> - rm -f csv
> - rm -f csvsummary
> + rm -f "${perfdata}"
> + rm -f "${perfdata}".old
> rm -rf "$tmpdir"
> +
> trap - exit term int
> }
>
> @@ -61,7 +64,7 @@ skip_no_probe_record_support() {
>
> prepare_perf_data() {
> # 1s should be sufficient to catch at least some switches
> - perf record -e sched:sched_switch -a -- sleep 1 > /dev/null 2>&1
> + perf record -e sched:sched_switch -a -o "${perfdata}" -- sleep 1 > /dev/null 2>&1
I'm not sure why it's needed.
Thanks,
Namhyung
> # check if perf data file got created in above step.
> if [ ! -e "perf.data" ]; then
> printf "FAIL: perf record failed to create \"perf.data\" \n"
> @@ -130,28 +133,28 @@ test_extended_times_summary_ns() {
> }
>
> test_csv() {
> - perf script report task-analyzer --csv csv > /dev/null
> - check_exec_0 "perf script report task-analyzer --csv csv"
> - find_str_or_fail "Comm;" csv "${FUNCNAME[0]}"
> + perf script report task-analyzer --csv "${csv}" > /dev/null
> + check_exec_0 "perf script report task-analyzer --csv ${csv}"
> + find_str_or_fail "Comm;" "${csv}" "${FUNCNAME[0]}"
> }
>
> test_csv_extended_times() {
> - perf script report task-analyzer --csv csv --extended-times > /dev/null
> - check_exec_0 "perf script report task-analyzer --csv csv --extended-times"
> - find_str_or_fail "Out-Out;" csv "${FUNCNAME[0]}"
> + perf script report task-analyzer --csv "${csv}" --extended-times > /dev/null
> + check_exec_0 "perf script report task-analyzer --csv ${csv} --extended-times"
> + find_str_or_fail "Out-Out;" "${csv}" "${FUNCNAME[0]}"
> }
>
> test_csvsummary() {
> - perf script report task-analyzer --csv-summary csvsummary > /dev/null
> - check_exec_0 "perf script report task-analyzer --csv-summary csvsummary"
> - find_str_or_fail "Comm;" csvsummary "${FUNCNAME[0]}"
> + perf script report task-analyzer --csv-summary "${csvsummary}" > /dev/null
> + check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary}"
> + find_str_or_fail "Comm;" "${csvsummary}" "${FUNCNAME[0]}"
> }
>
> test_csvsummary_extended() {
> - perf script report task-analyzer --csv-summary csvsummary --summary-extended \
> + perf script report task-analyzer --csv-summary "${csvsummary}" --summary-extended \
> >/dev/null
> - check_exec_0 "perf script report task-analyzer --csv-summary csvsummary --summary-extended"
> - find_str_or_fail "Out-Out;" csvsummary "${FUNCNAME[0]}"
> + check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary} --summary-extended"
> + find_str_or_fail "Out-Out;" "${csvsummary}" "${FUNCNAME[0]}"
> }
>
> skip_no_probe_record_support
> --
> 2.53.0.959.g497ff81fa9-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf tests task-analyzer: Write all test files to tmpdir
2026-03-26 22:37 ` Namhyung Kim
@ 2026-03-26 23:17 ` Ian Rogers
0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2026-03-26 23:17 UTC (permalink / raw)
To: Namhyung Kim
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, James Clark,
linux-perf-users, linux-kernel
On Thu, Mar 26, 2026 at 3:37 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Fri, Mar 20, 2026 at 11:16:24PM -0700, Ian Rogers wrote:
> > Writing to the test output files in the current working directory can
> > fail in various contexts such as continual test. Other tests write to
> > a mktemp-ed file, make the "perf script task-analyszer tests" follow
> > this convention too. Currently this isn't possible for the perf.data
> > file due to a lack of perf script support.
>
> I don't know what you mean by the last sentence.
>
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> > tools/perf/tests/shell/test_task_analyzer.sh | 37 +++++++++++---------
> > 1 file changed, 20 insertions(+), 17 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
> > index e194fcf61df3..cc74b03477fe 100755
> > --- a/tools/perf/tests/shell/test_task_analyzer.sh
> > +++ b/tools/perf/tests/shell/test_task_analyzer.sh
> > @@ -3,6 +3,10 @@
> > # SPDX-License-Identifier: GPL-2.0
> >
> > tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
> > +# perf script report only supports input from the perf.data file.
> > +perfdata="perf.data"
>
> I thought you want to use a different file name. What's the point of
> adding a variable here?
Let me cleanup the commit message in v2. The variable's purpose is to
allow us to update it when perf script supports the -i flag with
script files.
Thanks,
Ian
>
> > +csv="$tmpdir/csv"
> > +csvsummary="$tmpdir/csvsummary"
> > err=0
> >
> > # set PERF_EXEC_PATH to find scripts in the source directory
> > @@ -15,11 +19,10 @@ fi
> > export ASAN_OPTIONS=detect_leaks=0
> >
> > cleanup() {
> > - rm -f perf.data
> > - rm -f perf.data.old
> > - rm -f csv
> > - rm -f csvsummary
> > + rm -f "${perfdata}"
> > + rm -f "${perfdata}".old
> > rm -rf "$tmpdir"
> > +
> > trap - exit term int
> > }
> >
> > @@ -61,7 +64,7 @@ skip_no_probe_record_support() {
> >
> > prepare_perf_data() {
> > # 1s should be sufficient to catch at least some switches
> > - perf record -e sched:sched_switch -a -- sleep 1 > /dev/null 2>&1
> > + perf record -e sched:sched_switch -a -o "${perfdata}" -- sleep 1 > /dev/null 2>&1
>
> I'm not sure why it's needed.
>
> Thanks,
> Namhyung
>
>
> > # check if perf data file got created in above step.
> > if [ ! -e "perf.data" ]; then
> > printf "FAIL: perf record failed to create \"perf.data\" \n"
> > @@ -130,28 +133,28 @@ test_extended_times_summary_ns() {
> > }
> >
> > test_csv() {
> > - perf script report task-analyzer --csv csv > /dev/null
> > - check_exec_0 "perf script report task-analyzer --csv csv"
> > - find_str_or_fail "Comm;" csv "${FUNCNAME[0]}"
> > + perf script report task-analyzer --csv "${csv}" > /dev/null
> > + check_exec_0 "perf script report task-analyzer --csv ${csv}"
> > + find_str_or_fail "Comm;" "${csv}" "${FUNCNAME[0]}"
> > }
> >
> > test_csv_extended_times() {
> > - perf script report task-analyzer --csv csv --extended-times > /dev/null
> > - check_exec_0 "perf script report task-analyzer --csv csv --extended-times"
> > - find_str_or_fail "Out-Out;" csv "${FUNCNAME[0]}"
> > + perf script report task-analyzer --csv "${csv}" --extended-times > /dev/null
> > + check_exec_0 "perf script report task-analyzer --csv ${csv} --extended-times"
> > + find_str_or_fail "Out-Out;" "${csv}" "${FUNCNAME[0]}"
> > }
> >
> > test_csvsummary() {
> > - perf script report task-analyzer --csv-summary csvsummary > /dev/null
> > - check_exec_0 "perf script report task-analyzer --csv-summary csvsummary"
> > - find_str_or_fail "Comm;" csvsummary "${FUNCNAME[0]}"
> > + perf script report task-analyzer --csv-summary "${csvsummary}" > /dev/null
> > + check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary}"
> > + find_str_or_fail "Comm;" "${csvsummary}" "${FUNCNAME[0]}"
> > }
> >
> > test_csvsummary_extended() {
> > - perf script report task-analyzer --csv-summary csvsummary --summary-extended \
> > + perf script report task-analyzer --csv-summary "${csvsummary}" --summary-extended \
> > >/dev/null
> > - check_exec_0 "perf script report task-analyzer --csv-summary csvsummary --summary-extended"
> > - find_str_or_fail "Out-Out;" csvsummary "${FUNCNAME[0]}"
> > + check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary} --summary-extended"
> > + find_str_or_fail "Out-Out;" "${csvsummary}" "${FUNCNAME[0]}"
> > }
> >
> > skip_no_probe_record_support
> > --
> > 2.53.0.959.g497ff81fa9-goog
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-26 23:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 6:16 [PATCH v1] perf tests task-analyzer: Write all test files to tmpdir Ian Rogers
2026-03-26 22:37 ` Namhyung Kim
2026-03-26 23:17 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox