github.com/d4l3k/go@v0.0.0-20151015000803-65fc379daeda/misc/cgo/testsanitizers/test.bash (about) 1 #!/usr/bin/env bash 2 # Copyright 2015 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 # This directory is intended to test the use of Go with sanitizers 7 # like msan, asan, etc. See https://github.com/google/sanitizers . 8 9 set -e 10 11 # The sanitizers were originally developed with clang, so prefer it. 12 CC=cc 13 if test "$(type -p clang)" != ""; then 14 CC=clang 15 fi 16 export CC 17 18 if $CC -fsanitize=memory 2>&1 | grep "unrecognized" >& /dev/null; then 19 echo "skipping msan test: -fsanitize=memory not supported" 20 exit 0 21 fi 22 23 # The memory sanitizer in versions of clang before 3.6 don't work with Go. 24 if $CC --version | grep clang >& /dev/null; then 25 ver=$($CC --version | sed -e 's/.* version \([0-9.-]*\).*/\1/') 26 major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/') 27 minor=$(echo $ver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/') 28 if test $major -lt 3 || test $major -eq 3 -a $minor -lt 6; then 29 echo "skipping msan test; clang version $major.$minor older than 3.6" 30 exit 0 31 fi 32 fi 33 34 go run msan.go