[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221206154406.41941-4-petar.gligor@gmail.com>
Date: Tue, 6 Dec 2022 10:44:06 -0500
From: Petar Gligoric <petar.gligor@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Petar Gligoric <petar.gligoric@...de-schwarz.com>,
Hagen Paul Pfeifer <hagen@...u.net>,
Ian Rogers <irogers@...gle.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Andi Kleen <ak@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH v2 3/3] perf test: add new task-analyzer tests
From: Petar Gligoric <petar.gligoric@...de-schwarz.com>
Provide task-analyzer test cases for all possible arguments and a subset of possible
combinations.
12 Tests in total.
test_basic:
- cmd:"perf script report task-analyzer"
- Fundamental test of script without arguments.
- Check for standard output.
test_ns_rename:
- cmd:"perf script report task-analyzer --ns --rename-comms-by-tids 0:random"
- Standard task with timestamps in nanoseconds and comm renamed.
- Check for standard output.
test_ms_filtertasks_highlight:
- cmd:"perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf"
- Standard task with timestamps in milliseconds, task filtered out and highlighted.
- Check for standard output.
test_extended_times_timelimit_limittasks:
- cmd "perf script report task-analyzer --extended-times --time-limit :99999"
- Standard task with additional schedule out/in info and timlimit active at 99999.
- Check for extended table output.
test_summary:
- cmd:"perf script report task-analyzer --summary"
- Standard task with additional summary output.
- Check for summary print.
test_summary_extended:
- cmd:"perf script report task-analyzer --summary-extended"
- Standard task with summary and additional schedule in/out info.
- Chceck for extended table print.
test_summaryonly:
- cmd:"perf script report task-analyzer --summary-only"
- Only summary should be printed.
- Check for summary print.
test_extended_times_summary_ns:
- cmd:"perf script report task-analyzer --extended-times --summary --ns"
- Standard task with extended schedule in/out information and summary in ns.
- Check for extended table and summary.
test_csv:
- cmd:"perf script report task-analyzer --csv csv"
- Print standard task to csv file in csv format.
- Check for csv format.
test_csv_extended_times:
- cmd:"perf script report task-analyzer --csv csv --extended-times"
- Print standard task to csv file in csv format with additional schedule in/out
information.
- Check for additional information and csv format.
test_csvsummary:
- cmd:"perf script report task-analyzer --csv-summary csvsummary"
- Print summary to csvsummary file in csv format.
- Check for csv format.
test_csvsummary_extended:
- cmd:"perf script report task-analyzer --csv-summary csvsummary --summary-extended"
- Print summary to csvsummary file in csv format with additional schedule in/out
information.
- Check for additional information and csv format.
Signed-off-by: Petar Gligoric <petar.gligoric@...de-schwarz.com>
Signed-off-by: Hagen Paul Pfeifer <hagen@...u.net>
Suggested-by: Ian Rogers <irogers@...gle.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>
Cc: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/tests/shell/test_task_analyzer.sh | 151 +++++++++++++++++++
1 file changed, 151 insertions(+)
create mode 100755 tools/perf/tests/shell/test_task_analyzer.sh
diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/tests/shell/test_task_analyzer.sh
new file mode 100755
index 000000000000..a98e4ab66040
--- /dev/null
+++ b/tools/perf/tests/shell/test_task_analyzer.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+# perf script task-analyzer tests
+# SPDX-License-Identifier: GPL-2.0
+
+tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
+err=0
+
+cleanup() {
+ rm -f perf.data
+ rm -f perf.data.old
+ rm -f csv
+ rm -f csvsummary
+ rm -rf $tmpdir
+ trap - exit term int
+}
+
+trap_cleanup() {
+ cleanup
+ exit 1
+}
+trap trap_cleanup exit term int
+
+report() {
+ if [ $1 = 0 ]; then
+ echo "PASS: \"$2\""
+ else
+ echo "FAIL: \"$2\" Error message: \"$3\""
+ err=1
+ fi
+}
+
+check_exec_0() {
+ if [ $? != 0 ]; then
+ report 1 "invokation of ${$1} command failed"
+ fi
+}
+
+find_str_or_fail() {
+ grep -q "$1" $2
+ if [ $? != 0 ]; then
+ report 1 $3 "Failed to find required string:'${1}'."
+ else
+ report 0 $3
+ fi
+}
+
+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
+}
+
+# check standard inkvokation with no arguments
+test_basic() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Comm" $out ${FUNCNAME[0]}
+}
+
+test_ns_rename(){
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --ns --rename-comms-by-tids 0:random > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Comm" $out ${FUNCNAME[0]}
+}
+
+test_ms_filtertasks_highlight(){
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf \
+ > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Comm" $out ${FUNCNAME[0]}
+}
+
+test_extended_times_timelimit_limittasks() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --extended-times --time-limit :99999 \
+ --limit-to-tasks perf > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Out-Out" $out ${FUNCNAME[0]}
+}
+
+test_summary() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --summary > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Summary" $out ${FUNCNAME[0]}
+}
+
+test_summaryextended() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --summary-extended > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Inter Task Times" $out ${FUNCNAME[0]}
+}
+
+test_summaryonly() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --summary-only > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Summary" $out ${FUNCNAME[0]}
+}
+
+test_extended_times_summary_ns() {
+ out="$tmpdir/perf.out"
+ perf script report task-analyzer --extended-times --summary --ns > $out
+ check_exec_0 "perf"
+ find_str_or_fail "Out-Out" $out ${FUNCNAME[0]}
+ find_str_or_fail "Summary" $out ${FUNCNAME[0]}
+}
+
+test_csv() {
+ perf script report task-analyzer --csv csv > /dev/null
+ check_exec_0 "perf"
+ 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"
+ 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"
+ find_str_or_fail "Comm;" csvsummary ${FUNCNAME[0]}
+}
+
+test_csvsummary_extended() {
+ perf script report task-analyzer --csv-summary csvsummary --summary-extended \
+ >/dev/null
+ check_exec_0 "perf"
+ find_str_or_fail "Out-Out;" csvsummary ${FUNCNAME[0]}
+}
+
+prepare_perf_data
+test_basic
+test_ns_rename
+test_ms_filtertasks_highlight
+test_extended_times_timelimit_limittasks
+test_summary
+test_summaryextended
+test_summaryonly
+test_extended_times_summary_ns
+test_csv
+test_csvsummary
+test_csv_extended_times
+test_csvsummary_extended
+cleanup
+exit $err
--
2.30.2
Powered by blists - more mailing lists