Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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 | |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 6 | set -u |
| 7 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 15 | PrintRes() { |
| 16 | printf "%s\n" "$RES" |
| 17 | } |
| 18 | |
| 19 | PrintRes |
| 20 | |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 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 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 29 | for f in write1; do |
| 30 | check $f rsp 1 |
| 31 | check $f push 2 |
| 32 | check $f pop 2 |
| 33 | done |
| 34 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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 |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 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 |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 50 | check $f pop 5 |
| 51 | done |
| 52 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 53 | for f in func_entry func_exit; do |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 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 |