From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options
Date: Tue, 24 Nov 2026 15:45:52 -0300 [thread overview]
Message-ID: <20261124184604.24983-6-acme@kernel.org> (raw)
In-Reply-To: <20261124184604.24983-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The script test only runs the parallel-perf script. Cover the script
list, a wide -F field set and the +field/-field syntax, per-event dumps,
the data file header, the task and mmap event display and the reltime,
deltatime, show-info, latency, ns and raw dump options.
The list is read from the scripts dir in the perf exec path, which in a
build tree points at a prefix that was never installed, so point
PERF_EXEC_PATH at the source tree when it is unset. A missing python3
or parallel-perf.py is a skip only when nothing failed above, otherwise
the exit status hides the failure behind an exit 2, which perf test
reports as skipped.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/shell/script.sh | 131 ++++++++++++++++++++++++++++++-
1 file changed, 129 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh
index af687c7cfe44c2c6..a74d45d51ae47cb1 100755
--- a/tools/perf/tests/shell/script.sh
+++ b/tools/perf/tests/shell/script.sh
@@ -4,6 +4,22 @@
set -e
+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
+# perf script -l reads the scripts directory from the perf exec path,
+# which in a build tree points at a prefix that is not installed
+if [ -z "${PERF_EXEC_PATH}" ] && [ -d "${shelldir}"/../../python ]; then
+ PERF_EXEC_PATH=$(cd "${shelldir}"/../.. && pwd)
+ export PERF_EXEC_PATH
+fi
+
+testprog="perf test -w thloop"
+testsym="test_loop"
+
+skip_test_missing_symbol "${testsym}"
+
temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX)
err=0
@@ -27,18 +43,123 @@ trap_cleanup()
trap trap_cleanup EXIT TERM INT
+script_data="${temp_dir}/script-perf.data"
+
+test_script_list()
+{
+ echo "perf script list test"
+ if ! perf script -l | grep -q "List of available scripts"
+ then
+ echo "perf script list test [Failed missing list header]"
+ err=1
+ return
+ fi
+ if ! perf script -l | grep -q "export-to-sqlite"
+ then
+ echo "perf script list test [Failed missing export-to-sqlite]"
+ err=1
+ fi
+}
+
+test_script_fields()
+{
+ echo "perf script fields test"
+ perf record -o "${script_data}" -e cpu-clock --sample-cpu ${testprog}
+ if ! perf script -i "${script_data}" -F comm,tid,pid,time,cpu,event,ip,sym,dso,dsoff,symoff,period,machine_pid,vcpu,ipc,insn,insnlen,disasm,misc,metric,synth,callindent,flags | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed missing ${testsym}]"
+ err=1
+ return
+ fi
+ if ! perf script -i "${script_data}" -F +cpu | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed to add the cpu field]"
+ err=1
+ fi
+ if ! perf script -i "${script_data}" -F -comm | grep -q "${testsym}"
+ then
+ echo "perf script fields test [Failed to remove the comm field]"
+ err=1
+ fi
+}
+
+test_script_per_event_dump()
+{
+ echo "perf script per-event dump test"
+ if ! perf script -i "${script_data}" --per-event-dump > /dev/null
+ then
+ echo "perf script per-event dump test [Failed to write the dumps]"
+ err=1
+ return
+ fi
+ if ! grep -q "${testsym}" "${script_data}".*.dump
+ then
+ echo "perf script per-event dump test [Failed missing ${testsym}]"
+ err=1
+ fi
+}
+
+test_script_header()
+{
+ echo "perf script header test"
+ if ! perf script -i "${script_data}" --header | grep -q "captured on"
+ then
+ echo "perf script header test [Failed missing the header]"
+ err=1
+ return
+ fi
+ if ! perf script -i "${script_data}" --header-only | grep -q "captured on"
+ then
+ echo "perf script header test [Failed missing the header only output]"
+ err=1
+ fi
+}
+
+test_script_events()
+{
+ echo "perf script events test"
+ if ! perf script -i "${script_data}" --show-task-events --show-mmap-events | grep -q "PERF_RECORD_"
+ then
+ echo "perf script events test [Failed missing the events]"
+ err=1
+ fi
+}
+
+test_script_misc()
+{
+ echo "perf script misc options test"
+ for opt in --reltime --deltatime -I -L --ns
+ do
+ if ! perf script -i "${script_data}" ${opt} | grep -q "${testsym}"
+ then
+ echo "perf script misc options test [Failed ${opt}]"
+ err=1
+ fi
+ done
+ if ! perf script -i "${script_data}" -D | grep -q "PERF_RECORD_SAMPLE"
+ then
+ echo "perf script misc options test [Failed --dump-raw-trace]"
+ err=1
+ fi
+}
+
test_parallel_perf()
{
echo "parallel-perf test"
if ! python3 --version >/dev/null 2>&1 ; then
echo "SKIP: no python3"
- err=2
+ # Don't turn a failure in the tests above into a skip
+ if [ ${err} -eq 0 ]; then
+ err=2
+ fi
return
fi
pp=$(dirname "$0")/../../python/parallel-perf.py
if [ ! -f "${pp}" ] ; then
echo "SKIP: parallel-perf.py script not found "
- err=2
+ if [ ${err} -eq 0 ]; then
+ err=2
+ fi
return
fi
perf_data="${temp_dir}/pp-perf.data"
@@ -50,6 +171,12 @@ test_parallel_perf()
echo "parallel-perf test [Success]"
}
+test_script_list
+test_script_fields
+test_script_per_event_dump
+test_script_header
+test_script_events
+test_script_misc
test_parallel_perf
cleanup
--
2.56.0
next prev parent reply other threads:[~2026-11-24 18:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` Arnaldo Carvalho de Melo [this message]
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124184604.24983-6-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®