mirror of https://github.com/golang/go.git
misc/cgo/testsanitizers: accept compilers that don't report location
It appears that GCC before version 10 doesn't report file/line location for asan errors. Change-Id: I03ee24180ba365636596aa2384961df7ce6ed71f Reviewed-on: https://go-review.googlesource.com/c/go/+/374874 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
8a306e2056
commit
6178d25fc0
|
|
@ -63,7 +63,11 @@ func TestASAN(t *testing.T) {
|
|||
// symbolizer program and can't find it.
|
||||
const noSymbolizer = "external symbolizer"
|
||||
// Check if -asan option can correctly print where the error occured.
|
||||
if tc.errorLocation != "" && !strings.Contains(out, tc.errorLocation) && !strings.Contains(out, noSymbolizer) {
|
||||
if tc.errorLocation != "" &&
|
||||
!strings.Contains(out, tc.errorLocation) &&
|
||||
!strings.Contains(out, noSymbolizer) &&
|
||||
compilerSupportsLocation() {
|
||||
|
||||
t.Errorf("%#q exited without expected location of the error\n%s; got failure\n%s", strings.Join(cmd.Args, " "), tc.errorLocation, out)
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -218,6 +218,23 @@ func compilerVersion() (version, error) {
|
|||
return compiler.version, compiler.err
|
||||
}
|
||||
|
||||
// compilerSupportsLocation reports whether the compiler should be
|
||||
// able to provide file/line information in backtraces.
|
||||
func compilerSupportsLocation() bool {
|
||||
compiler, err := compilerVersion()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
switch compiler.name {
|
||||
case "gcc":
|
||||
return compiler.major >= 10
|
||||
case "clang":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
type compilerCheck struct {
|
||||
once sync.Once
|
||||
err error
|
||||
|
|
|
|||
Loading…
Reference in New Issue