1b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany#!/bin/bash
2b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryanyset -u
3b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
4b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya SerebryanyRES=$(./analyze_libtsan.sh)
5b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya SerebryanyPrintRes() {
6b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  printf "%s\n" "$RES"
7b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany}
8b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
9b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya SerebryanyPrintRes
10b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
11b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryanycheck() {
12b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  res=$(PrintRes | egrep "$1 .* $2 $3; ")
13b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  if [ "$res" == "" ]; then
14b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany    echo FAILED $1 must contain $2 $3
15b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany    exit 1
16b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  fi
17b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany}
18b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
1986277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesfor f in write1; do
2086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f rsp 1
2186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f push 2
2286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f pop 2
236a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hinesdone
246a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines
2586277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesfor f in write2 write4 write8; do
2686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f rsp 1
2786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f push 3
2886277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f pop 3
2986277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesdone
3086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines
3186277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesfor f in read1 read2 read4 read8; do
3286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f rsp 1
3386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f push 5
3486277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  check $f pop 5
35b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryanydone
36b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
3786277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesfor f in func_entry func_exit; do
38b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  check $f rsp 0
39b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  check $f push 0
40b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  check $f pop 0
41b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany  check $f call 1  # TraceSwitch()
42b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryanydone
43b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryany
44b82ae88720750d0ad4fd829c84e0dd0f8708cc2bKostya Serebryanyecho LGTM
45