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 6set -u 7 8if [[ "$#" != 1 ]]; then 9 echo "Usage: $0 /path/to/binary/built/with/tsan" 10 exit 1 11fi 12 13SCRIPTDIR=$(dirname $0) 14RES=$(${SCRIPTDIR}/analyze_libtsan.sh $1) 15PrintRes() { 16 printf "%s\n" "$RES" 17} 18 19PrintRes 20 21check() { 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 29for f in write1; do 30 check $f rsp 1 31 check $f push 2 32 check $f pop 2 33done 34 35for f in write2 write4; do 36 check $f rsp 1 37 check $f push 4 38 check $f pop 4 39done 40 41for f in write8; do 42 check $f rsp 1 43 check $f push 3 44 check $f pop 3 45done 46 47for f in read1 read2 read4 read8; do 48 check $f rsp 1 49 check $f push 5 50 check $f pop 5 51done 52 53for 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() 58done 59 60echo LGTM 61