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