diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-12-29 11:19:13 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-12-29 20:20:32 +0000 |
commit | 6178d25fc0b28724b1b5aec2b1b74fc06d9294c7 (patch) | |
tree | 8642089d0e3b8f460638082641ab3728979529ed /misc | |
parent | 8a306e205663cde672e9920e2e81db9d3615e6c0 (diff) | |
download | go-git-6178d25fc0b28724b1b5aec2b1b74fc06d9294c7.tar.gz |
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>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cgo/testsanitizers/asan_test.go | 6 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/cc_test.go | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/misc/cgo/testsanitizers/asan_test.go b/misc/cgo/testsanitizers/asan_test.go index ed58e5a183..27bd8a5b1f 100644 --- a/misc/cgo/testsanitizers/asan_test.go +++ b/misc/cgo/testsanitizers/asan_test.go @@ -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 diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go index 0ce4f75935..05b77932b4 100644 --- a/misc/cgo/testsanitizers/cc_test.go +++ b/misc/cgo/testsanitizers/cc_test.go @@ -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 |