1 #!/bin/sh 2 # perf diff tests 3 # SPDX-License-Identifier: GPL-2.0 4 5 set -e 6 7 err=0 8 perfdata1=$(mktemp /tmp/__perf_test.perf.data. 9 perfdata2=$(mktemp /tmp/__perf_test.perf.data. 10 perfdata3=$(mktemp /tmp/__perf_test.perf.data. 11 testprog="perf test -w thloop" 12 13 shelldir=$(dirname "$0") 14 # shellcheck source=lib/perf_has_symbol.sh 15 . "${shelldir}"/lib/perf_has_symbol.sh 16 17 testsym="test_loop" 18 19 skip_test_missing_symbol ${testsym} 20 21 cleanup() { 22 rm -rf "${perfdata1}" 23 rm -rf "${perfdata1}".old 24 rm -rf "${perfdata2}" 25 rm -rf "${perfdata2}".old 26 rm -rf "${perfdata3}" 27 rm -rf "${perfdata3}".old 28 29 trap - EXIT TERM INT 30 } 31 32 trap_cleanup() { 33 cleanup 34 exit 1 35 } 36 trap trap_cleanup EXIT TERM INT 37 38 make_data() { 39 file="$1" 40 if ! perf record -o "${file}" ${testprog} 2> 41 then 42 echo "Workload record [Failed record]" 43 echo 1 44 return 45 fi 46 if ! perf report -i "${file}" -q | grep -q " 47 then 48 echo "Workload record [Failed missing outp 49 echo 1 50 return 51 fi 52 echo 0 53 } 54 55 test_two_files() { 56 echo "Basic two file diff test" 57 err=$(make_data "${perfdata1}") 58 if [ $err != 0 ] 59 then 60 return 61 fi 62 err=$(make_data "${perfdata2}") 63 if [ $err != 0 ] 64 then 65 return 66 fi 67 68 if ! perf diff "${perfdata1}" "${perfdata2}" 69 then 70 echo "Basic two file diff test [Failed dif 71 err=1 72 return 73 fi 74 echo "Basic two file diff test [Success]" 75 } 76 77 test_three_files() { 78 echo "Basic three file diff test" 79 err=$(make_data "${perfdata1}") 80 if [ $err != 0 ] 81 then 82 return 83 fi 84 err=$(make_data "${perfdata2}") 85 if [ $err != 0 ] 86 then 87 return 88 fi 89 err=$(make_data "${perfdata3}") 90 if [ $err != 0 ] 91 then 92 return 93 fi 94 95 if ! perf diff "${perfdata1}" "${perfdata2}" 96 then 97 echo "Basic three file diff test [Failed d 98 err=1 99 return 100 fi 101 echo "Basic three file diff test [Success]" 102 } 103 104 test_two_files 105 test_three_files 106 107 cleanup 108 exit $err
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.