1 #!/bin/bash 2 # 3 # Script that checks that critical functions in TSan runtime have correct number 4 # of push/pop/rsp instructions to verify that runtime is efficient enough. 5 6 set -u 7 8 if [[ "$#" != 1 ]]; then 9 echo "Usage: $0 /path/to/binary/built/with/tsan" 10 exit 1 11 fi 12 13 SCRIPTDIR=$(dirname $0) 14 RES=$(${SCRIPTDIR}/analyze_libtsan.sh $1) 15 PrintRes() { 16 printf "%s\n" "$RES" 17 } 18 19 PrintRes 20 21 check() { 22 res=$(PrintRes | egrep "$1 .* $2 $3; ") 23 if [ "$res" == "" ]; then 24 echo FAILED $1 must contain $2 $3 25 exit 1 26 fi 27 } 28 29 for f in write1; do 30 check $f rsp 1 31 check $f push 2 32 check $f pop 2 33 done 34 35 for f in write2 write4; do 36 check $f rsp 1 37 check $f push 4 38 check $f pop 4 39 done 40 41 for f in write8; do 42 check $f rsp 1 43 check $f push 3 44 check $f pop 3 45 done 46 47 for f in read1 read2 read4 read8; do 48 check $f rsp 1 49 check $f push 5 50 check $f pop 5 51 done 52 53 for f in func_entry func_exit; do 54 check $f rsp 0 55 check $f push 0 56 check $f pop 0 57 check $f call 1 # TraceSwitch() 58 done 59 60 echo LGTM 61