Skip to content

Commit

Permalink
perf test shell tpebs: Extra verbosity on failure
Browse files Browse the repository at this point in the history
I've encountered occasional test failures with this test. Add verbose
output on failure to help diagnose the issue.

Signed-off-by: Ian Rogers <[email protected]>
  • Loading branch information
captain5050 committed Dec 20, 2024
1 parent 49f2e7b commit 4013941
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions tools/perf/tests/shell/test_stat_intel_tpebs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ then
exit 2
fi

cleanup() {
trap - EXIT TERM INT
}

trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT

# Use this event for testing because it should exist in all platforms
event=cache-misses:R

Expand All @@ -31,8 +42,36 @@ alt_name=/cache-misses/R
#result=$(perf stat -e "$event" true 2>&1)
#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1

# In platforms that do not support TPEBS, it should execute without error.
echo "Testing with --record-tpebs"
result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
[[ "$result" =~ "perf record" && "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
echo "Success!"
test_with_record_tpebs() {
echo "Testing with --record-tpebs"
result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)

# Expected output:
# $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
# Events enabled
# [ perf record: Woken up 2 times to write data ]
# [ perf record: Captured and wrote 0.056 MB - ]
#
# Performance counter stats for 'system wide':
#
# 0 cache-misses:R
#
# 0.013963299 seconds time elapsed
if [[ ! "$result" =~ "perf record" ]]
then
echo "Testing with --record-tpebs [Failed missing perf record]"
echo "$result"
exit 1
fi
if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
then
echo "Testing with --record-tpebs [Failed missing event name]"
echo "$result"
exit 1
fi
echo "Testing with --record-tpebs [Success]"
}

test_with_record_tpebs
cleanup
exit 0

0 comments on commit 4013941

Please sign in to comment.