perf test: add new task-analyzer tests

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.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20221206154406.41941-4-petar.gligor@gmail.com
Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Petar Gligoric 2022-12-06 10:44:06 -05:00 коммит произвёл Arnaldo Carvalho de Melo
Родитель fdd0f81f05
Коммит e8478b84d6
1 изменённых файлов: 151 добавлений и 0 удалений

Просмотреть файл

@ -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