blob: 0f6cc0698471e34e968cc50d0965999928d7c350 [file] [log] [blame]
Kostya Serebryanyb82ae882012-05-10 15:10:03 +00001#!/bin/bash
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08002#
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 Serebryanyb82ae882012-05-10 15:10:03 +00006set -u
7
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08008if [[ "$#" != 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)
Kostya Serebryanyb82ae882012-05-10 15:10:03 +000015PrintRes() {
16 printf "%s\n" "$RES"
17}
18
19PrintRes
20
Kostya Serebryanyb82ae882012-05-10 15:10:03 +000021check() {
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 Hines86277eb2015-03-23 12:06:32 -070029for f in write1; do
30 check $f rsp 1
31 check $f push 2
32 check $f pop 2
33done
34
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080035for 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
Stephen Hines86277eb2015-03-23 12:06:32 -070042 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
Stephen Hines6a211c52014-07-21 00:49:56 -070050 check $f pop 5
51done
52
Stephen Hines86277eb2015-03-23 12:06:32 -070053for f in func_entry func_exit; do
Kostya Serebryanyb82ae882012-05-10 15:10:03 +000054 check $f rsp 0
55 check $f push 0
56 check $f pop 0
57 check $f call 1 # TraceSwitch()
58done
59
60echo LGTM