test_stat_intel_tpebs.sh 676 B

12345678910111213141516171819
  1. #!/bin/bash
  2. # test Intel TPEBS counting mode
  3. # SPDX-License-Identifier: GPL-2.0
  4. set -e
  5. grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
  6. # Use this event for testing because it should exist in all platforms
  7. event=cache-misses:R
  8. # Without this cmd option, default value or zero is returned
  9. echo "Testing without --record-tpebs"
  10. result=$(perf stat -e "$event" true 2>&1)
  11. [[ "$result" =~ $event ]] || exit 1
  12. # In platforms that do not support TPEBS, it should execute without error.
  13. echo "Testing with --record-tpebs"
  14. result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
  15. [[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1