1 #!/bin/bash 2 3 # Where to install Valgrind with ThreadSanitizer. 4 VALGRIND_INST_ROOT="$1" 5 SVN_ROOT="$2" 6 7 if [ "$VALGRIND_INST_ROOT" == "" ]; then 8 echo "Usage: $0 /tsan/installation/path [svn/root/dir]" 9 exit 10 fi 11 12 if [ "$SVN_ROOT" == "" ]; then 13 # Get ThreadSanitizer. This will create directory 'drt' 14 svn co http://data-race-test.googlecode.com/svn/trunk drt || exit 1 15 cd drt || exit 1 16 else 17 cd $SVN_ROOT || exit 1 18 fi 19 20 TOPDIR=`pwd` 21 22 VG_ARCH=$(uname -m | sed -e "s/i.86/x86/;s/x86_64/amd64/;s/arm.*/arm/") 23 24 # Translate OS to valgrind-style identifiers 25 OS=`uname -s` 26 if [ "$OS" == "Linux" ]; then 27 VG_OS="linux" 28 elif [ "$OS" == "Darwin" ]; then 29 VG_OS="darwin" 30 fi 31 32 if ! echo -n "$OS $VG_ARCH" | \ 33 grep "\(Linux \(amd64\|x86\)\)\|Darwin x86" >/dev/null 34 then 35 echo "ThreadSanitizer is not yet supported on $OS $VG_ARCH" 36 exit 1 37 fi 38 39 echo ------------------------------------------------ 40 echo Building ThreadSanitizer for $OS $VG_ARCH 41 echo ------------------------------------------------ 42 sleep 1 43 44 # Build Valgind. 45 cd $TOPDIR/third_party || exit 1 46 ./update_valgrind.sh || exit 1 47 ./build_and_install_valgrind.sh $VALGRIND_INST_ROOT || exit 1 48 49 cd $TOPDIR/tsan || exit 1 50 make -s -j4 OFFLINE= GTEST_ROOT= PIN_ROOT= VALGRIND_INST_ROOT=$VALGRIND_INST_ROOT || exit 1 51 # Build the self contained binaries. 52 make self-contained OS=$VG_OS ARCH=$VG_ARCH VALGRIND_INST_ROOT=$VALGRIND_INST_ROOT || exit 1 53 54 TSAN=$TOPDIR/tsan/bin/tsan-$VG_ARCH-$VG_OS-self-contained.sh 55 56 # Test 57 cd $TOPDIR/unittest || exit 1 58 make all -s -j4 OS=${VG_OS} ARCH=${VG_ARCH} OPT=1 STATIC=0 || exit 1 59 $TSAN --color bin/demo_tests-${VG_OS}-${VG_ARCH}-O1 --gtest_filter="DemoTests.RaceReportDemoTest" || exit 1 60 61 # Done 62 echo "ThreadSanitizer is built: $TSAN" 63