diff options
Diffstat (limited to 'tools/perf/tests/shell')
-rw-r--r-- | tools/perf/tests/shell/lib/perf_json_output_lint.py | 3 | ||||
-rwxr-xr-x | tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 3 | ||||
-rwxr-xr-x | tools/perf/tests/shell/record_offcpu.sh | 2 | ||||
-rwxr-xr-x | tools/perf/tests/shell/stat+csv_output.sh | 58 | ||||
-rwxr-xr-x | tools/perf/tests/shell/stat+json_output.sh | 48 | ||||
-rwxr-xr-x | tools/perf/tests/shell/test_arm_coresight.sh | 24 |
6 files changed, 105 insertions, 33 deletions
diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/perf/tests/shell/lib/perf_json_output_lint.py index 97598d14e532..61f3059ca54b 100644 --- a/tools/perf/tests/shell/lib/perf_json_output_lint.py +++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py @@ -17,9 +17,10 @@ ap.add_argument('--per-thread', action='store_true') ap.add_argument('--per-die', action='store_true') ap.add_argument('--per-node', action='store_true') ap.add_argument('--per-socket', action='store_true') +ap.add_argument('--file', type=argparse.FileType('r'), default=sys.stdin) args = ap.parse_args() -Lines = sys.stdin.readlines() +Lines = args.file.readlines() def isfloat(num): try: diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh index b4149b2db4c6..bbb5b3d185fa 100755 --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh @@ -38,8 +38,6 @@ trace_libc_inet_pton_backtrace() { case "$(uname -m)" in s390x) eventattr='call-graph=dwarf,max-stack=4' - echo "text_to_binary_address.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected - echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected ;; @@ -51,7 +49,6 @@ trace_libc_inet_pton_backtrace() { ;; *) eventattr='max-stack=3' - echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected ;; esac diff --git a/tools/perf/tests/shell/record_offcpu.sh b/tools/perf/tests/shell/record_offcpu.sh index e01973d4e0fb..f062ae9a95e1 100755 --- a/tools/perf/tests/shell/record_offcpu.sh +++ b/tools/perf/tests/shell/record_offcpu.sh @@ -65,7 +65,7 @@ test_offcpu_child() { # perf bench sched messaging creates 400 processes if ! perf record --off-cpu -e dummy -o ${perfdata} -- \ - perf bench sched messaging -g 10 > /dev/null 2&>1 + perf bench sched messaging -g 10 > /dev/null 2>&1 then echo "Child task off-cpu test [Failed record]" err=1 diff --git a/tools/perf/tests/shell/stat+csv_output.sh b/tools/perf/tests/shell/stat+csv_output.sh index 324fc9e6edd7..fb78b6251a4e 100755 --- a/tools/perf/tests/shell/stat+csv_output.sh +++ b/tools/perf/tests/shell/stat+csv_output.sh @@ -9,6 +9,20 @@ set -e skip_test=0 csv_sep=@ +stat_output=$(mktemp /tmp/__perf_test.stat_output.csv.XXXXX) + +cleanup() { + rm -f "${stat_output}" + + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + function commachecker() { local -i cnt=0 @@ -30,9 +44,11 @@ function commachecker() while read line do - # Check for lines beginning with Failed - x=${line:0:6} - [ "$x" = "Failed" ] && continue + # Ignore initial "started on" comment. + x=${line:0:1} + [ "$x" = "#" ] && continue + # Ignore initial blank line. + [ "$line" = "" ] && continue # Count the number of commas x=$(echo $line | tr -d -c $csv_sep) @@ -42,7 +58,7 @@ function commachecker() echo "wrong number of fields. expected $exp in $line" 1>&2 exit 1; } - done + done < "${stat_output}" return 0 } @@ -55,7 +71,8 @@ function ParanoidAndNotRoot() check_no_args() { echo -n "Checking CSV output: no args " - perf stat -x$csv_sep true 2>&1 | commachecker --no-args + perf stat -x$csv_sep -o "${stat_output}" true + commachecker --no-args echo "[Success]" } @@ -67,27 +84,29 @@ check_system_wide() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep -a true 2>&1 | commachecker --system-wide + perf stat -x$csv_sep -a -o "${stat_output}" true + commachecker --system-wide echo "[Success]" } check_system_wide_no_aggr() { - echo -n "Checking CSV output: system wide " + echo -n "Checking CSV output: system wide no aggregation " if ParanoidAndNotRoot 0 then echo "[Skip] paranoid and not root" return fi - echo -n "Checking CSV output: system wide no aggregation " - perf stat -x$csv_sep -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr + perf stat -x$csv_sep -A -a --no-merge -o "${stat_output}" true + commachecker --system-wide-no-aggr echo "[Success]" } check_interval() { echo -n "Checking CSV output: interval " - perf stat -x$csv_sep -I 1000 true 2>&1 | commachecker --interval + perf stat -x$csv_sep -I 1000 -o "${stat_output}" true + commachecker --interval echo "[Success]" } @@ -95,7 +114,8 @@ check_interval() check_event() { echo -n "Checking CSV output: event " - perf stat -x$csv_sep -e cpu-clock true 2>&1 | commachecker --event + perf stat -x$csv_sep -e cpu-clock -o "${stat_output}" true + commachecker --event echo "[Success]" } @@ -107,7 +127,8 @@ check_per_core() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep --per-core -a true 2>&1 | commachecker --per-core + perf stat -x$csv_sep --per-core -a -o "${stat_output}" true + commachecker --per-core echo "[Success]" } @@ -119,7 +140,8 @@ check_per_thread() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep --per-thread -a true 2>&1 | commachecker --per-thread + perf stat -x$csv_sep --per-thread -a -o "${stat_output}" true + commachecker --per-thread echo "[Success]" } @@ -131,7 +153,8 @@ check_per_die() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep --per-die -a true 2>&1 | commachecker --per-die + perf stat -x$csv_sep --per-die -a -o "${stat_output}" true + commachecker --per-die echo "[Success]" } @@ -143,7 +166,8 @@ check_per_node() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep --per-node -a true 2>&1 | commachecker --per-node + perf stat -x$csv_sep --per-node -a -o "${stat_output}" true + commachecker --per-node echo "[Success]" } @@ -155,7 +179,8 @@ check_per_socket() echo "[Skip] paranoid and not root" return fi - perf stat -x$csv_sep --per-socket -a true 2>&1 | commachecker --per-socket + perf stat -x$csv_sep --per-socket -a -o "${stat_output}" true + commachecker --per-socket echo "[Success]" } @@ -202,4 +227,5 @@ then else echo "[Skip] Skipping tests for system_wide_no_aggr, per_core, per_die and per_socket since socket id exposed via topology is invalid" fi +cleanup exit 0 diff --git a/tools/perf/tests/shell/stat+json_output.sh b/tools/perf/tests/shell/stat+json_output.sh index 2c4212c641ed..f3e4967cc72e 100755 --- a/tools/perf/tests/shell/stat+json_output.sh +++ b/tools/perf/tests/shell/stat+json_output.sh @@ -23,6 +23,20 @@ then fi fi +stat_output=$(mktemp /tmp/__perf_test.stat_output.json.XXXXX) + +cleanup() { + rm -f "${stat_output}" + + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + # Return true if perf_event_paranoid is > $1 and not running as root. function ParanoidAndNotRoot() { @@ -32,7 +46,8 @@ function ParanoidAndNotRoot() check_no_args() { echo -n "Checking json output: no args " - perf stat -j true 2>&1 | $PYTHON $pythonchecker --no-args + perf stat -j -o "${stat_output}" true + $PYTHON $pythonchecker --no-args --file "${stat_output}" echo "[Success]" } @@ -44,27 +59,29 @@ check_system_wide() echo "[Skip] paranoia and not root" return fi - perf stat -j -a true 2>&1 | $PYTHON $pythonchecker --system-wide + perf stat -j -a -o "${stat_output}" true + $PYTHON $pythonchecker --system-wide --file "${stat_output}" echo "[Success]" } check_system_wide_no_aggr() { - echo -n "Checking json output: system wide " + echo -n "Checking json output: system wide no aggregation " if ParanoidAndNotRoot 0 then echo "[Skip] paranoia and not root" return fi - echo -n "Checking json output: system wide no aggregation " - perf stat -j -A -a --no-merge true 2>&1 | $PYTHON $pythonchecker --system-wide-no-aggr + perf stat -j -A -a --no-merge -o "${stat_output}" true + $PYTHON $pythonchecker --system-wide-no-aggr --file "${stat_output}" echo "[Success]" } check_interval() { echo -n "Checking json output: interval " - perf stat -j -I 1000 true 2>&1 | $PYTHON $pythonchecker --interval + perf stat -j -I 1000 -o "${stat_output}" true + $PYTHON $pythonchecker --interval --file "${stat_output}" echo "[Success]" } @@ -72,7 +89,8 @@ check_interval() check_event() { echo -n "Checking json output: event " - perf stat -j -e cpu-clock true 2>&1 | $PYTHON $pythonchecker --event + perf stat -j -e cpu-clock -o "${stat_output}" true + $PYTHON $pythonchecker --event --file "${stat_output}" echo "[Success]" } @@ -84,7 +102,8 @@ check_per_core() echo "[Skip] paranoia and not root" return fi - perf stat -j --per-core -a true 2>&1 | $PYTHON $pythonchecker --per-core + perf stat -j --per-core -a -o "${stat_output}" true + $PYTHON $pythonchecker --per-core --file "${stat_output}" echo "[Success]" } @@ -96,7 +115,8 @@ check_per_thread() echo "[Skip] paranoia and not root" return fi - perf stat -j --per-thread -a true 2>&1 | $PYTHON $pythonchecker --per-thread + perf stat -j --per-thread -a -o "${stat_output}" true + $PYTHON $pythonchecker --per-thread --file "${stat_output}" echo "[Success]" } @@ -108,7 +128,8 @@ check_per_die() echo "[Skip] paranoia and not root" return fi - perf stat -j --per-die -a true 2>&1 | $PYTHON $pythonchecker --per-die + perf stat -j --per-die -a -o "${stat_output}" true + $PYTHON $pythonchecker --per-die --file "${stat_output}" echo "[Success]" } @@ -120,7 +141,8 @@ check_per_node() echo "[Skip] paranoia and not root" return fi - perf stat -j --per-node -a true 2>&1 | $PYTHON $pythonchecker --per-node + perf stat -j --per-node -a -o "${stat_output}" true + $PYTHON $pythonchecker --per-node --file "${stat_output}" echo "[Success]" } @@ -132,7 +154,8 @@ check_per_socket() echo "[Skip] paranoia and not root" return fi - perf stat -j --per-socket -a true 2>&1 | $PYTHON $pythonchecker --per-socket + perf stat -j --per-socket -a -o "${stat_output}" true + $PYTHON $pythonchecker --per-socket --file "${stat_output}" echo "[Success]" } @@ -179,4 +202,5 @@ then else echo "[Skip] Skipping tests for system_wide_no_aggr, per_core, per_die and per_socket since socket id exposed via topology is invalid" fi +cleanup exit 0 diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/tests/shell/test_arm_coresight.sh index 565ce525c40b..482009e17bda 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -150,6 +150,8 @@ arm_cs_etm_system_wide_test() { echo "Recording trace with system wide mode" perf record -o ${perfdata} -e cs_etm// -a -- ls > /dev/null 2>&1 + # System-wide mode should include perf samples so test for that + # instead of ls perf_script_branch_samples perf && perf_report_branch_samples perf && perf_report_instruction_samples perf @@ -182,7 +184,29 @@ arm_cs_etm_snapshot_test() { arm_cs_report "CoreSight snapshot testing" $err } +arm_cs_etm_basic_test() { + echo "Recording trace with '$*'" + perf record -o ${perfdata} "$@" -- ls > /dev/null 2>&1 + + perf_script_branch_samples ls && + perf_report_branch_samples ls && + perf_report_instruction_samples ls + + err=$? + arm_cs_report "CoreSight basic testing with '$*'" $err +} + arm_cs_etm_traverse_path_test arm_cs_etm_system_wide_test arm_cs_etm_snapshot_test + +# Test all combinations of per-thread, system-wide and normal mode with +# and without timestamps +arm_cs_etm_basic_test -e cs_etm/timestamp=0/ --per-thread +arm_cs_etm_basic_test -e cs_etm/timestamp=1/ --per-thread +arm_cs_etm_basic_test -e cs_etm/timestamp=0/ -a +arm_cs_etm_basic_test -e cs_etm/timestamp=1/ -a +arm_cs_etm_basic_test -e cs_etm/timestamp=0/ +arm_cs_etm_basic_test -e cs_etm/timestamp=1/ + exit $glb_err |