record.sh (1796B)
1#!/bin/sh 2# perf record tests 3# SPDX-License-Identifier: GPL-2.0 4 5set -e 6 7err=0 8perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) 9 10cleanup() { 11 rm -f ${perfdata} 12 rm -f ${perfdata}.old 13 trap - exit term int 14} 15 16trap_cleanup() { 17 cleanup 18 exit 1 19} 20trap trap_cleanup exit term int 21 22test_per_thread() { 23 echo "Basic --per-thread mode test" 24 if ! perf record -e instructions:u -o ${perfdata} --quiet true 2> /dev/null 25 then 26 echo "Per-thread record [Skipped instructions:u not supported]" 27 if [ $err -ne 1 ] 28 then 29 err=2 30 fi 31 return 32 fi 33 if ! perf record -e instructions:u --per-thread -o ${perfdata} true 2> /dev/null 34 then 35 echo "Per-thread record of instructions:u [Failed]" 36 err=1 37 return 38 fi 39 if ! perf report -i ${perfdata} -q | egrep -q true 40 then 41 echo "Per-thread record [Failed missing output]" 42 err=1 43 return 44 fi 45 echo "Basic --per-thread mode test [Success]" 46} 47 48test_register_capture() { 49 echo "Register capture test" 50 if ! perf list | egrep -q 'br_inst_retired.near_call' 51 then 52 echo "Register capture test [Skipped missing instruction]" 53 if [ $err -ne 1 ] 54 then 55 err=2 56 fi 57 return 58 fi 59 if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15' 60 then 61 echo "Register capture test [Skipped missing registers]" 62 return 63 fi 64 if ! perf record -o - --intr-regs=di,r8,dx,cx -e cpu/br_inst_retired.near_call/p \ 65 -c 1000 --per-thread true 2> /dev/null \ 66 | perf script -F ip,sym,iregs -i - 2> /dev/null \ 67 | egrep -q "DI:" 68 then 69 echo "Register capture test [Failed missing output]" 70 err=1 71 return 72 fi 73 echo "Register capture test [Success]" 74} 75 76test_per_thread 77test_register_capture 78 79cleanup 80exit $err