diff options
author | Lynn Boger <laboger@linux.vnet.ibm.com> | 2022-08-24 12:14:20 -0500 |
---|---|---|
committer | Lynn Boger <laboger@linux.vnet.ibm.com> | 2022-08-25 11:40:57 +0000 |
commit | d4ff25ac69c90bb0e6a92aff7650d0bf3d41d29e (patch) | |
tree | 28276e593d16adc4adf26d6df2590ae96b43cf81 /misc/cgo | |
parent | 8c8429fe4113b399355c11203e60e6b37bc823ba (diff) | |
download | go-d4ff25ac69c90bb0e6a92aff7650d0bf3d41d29e.tar.gz go-d4ff25ac69c90bb0e6a92aff7650d0bf3d41d29e.zip |
misc/cgo/testsanitizers: determine compiler version for tsan tests on ppc64le
Some tests in misc/cgo/testsanitizers had been disabled on ppc64le
until recently, due to an intermittent error in the tsan tests,
with the goal of trying to understand the failure.
After further investigation, I found that the code for tsan within
gcc does not work consistently when ASLR is enabled on ppc64le. A
fix for that problem was integrated in gcc 9.
This adds a check to testsanitizers to determine the gcc compiler
version on ppc64le and skip the test if the version is too old.
A similar check is needed for asan too.
Updates #54645
Change-Id: I70717d1aa9e967cf1e871566e72b3862b91fea3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Diffstat (limited to 'misc/cgo')
-rw-r--r-- | misc/cgo/testsanitizers/asan_test.go | 4 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/cc_test.go | 18 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/cshared_test.go | 5 | ||||
-rw-r--r-- | misc/cgo/testsanitizers/tsan_test.go | 13 |
4 files changed, 37 insertions, 3 deletions
diff --git a/misc/cgo/testsanitizers/asan_test.go b/misc/cgo/testsanitizers/asan_test.go index dc1b5a1ecf..1c423add16 100644 --- a/misc/cgo/testsanitizers/asan_test.go +++ b/misc/cgo/testsanitizers/asan_test.go @@ -27,8 +27,8 @@ func TestASAN(t *testing.T) { // -asan option must use a compatible version of ASan library, which requires that // the gcc version is not less than 7 and the clang version is not less than 9, // otherwise a segmentation fault will occur. - if !compilerRequiredAsanVersion() { - t.Skipf("skipping: too old version of compiler") + if !compilerRequiredAsanVersion(goos, goarch) { + t.Skipf("skipping on %s/%s: too old version of compiler", goos, goarch) } t.Parallel() diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go index f447b5c89f..664083f570 100644 --- a/misc/cgo/testsanitizers/cc_test.go +++ b/misc/cgo/testsanitizers/cc_test.go @@ -252,14 +252,30 @@ func compilerSupportsLocation() bool { } } +// compilerRequiredTsanVersion reports whether the compiler is the version required by Tsan. +// Only restrictions for ppc64le are known; otherwise return true. +func compilerRequiredTsanVersion(goos, goarch string) bool { + compiler, err := compilerVersion() + if err != nil { + return false + } + if compiler.name == "gcc" && goarch == "ppc64le" { + return compiler.major >= 9 + } + return true +} + // compilerRequiredAsanVersion reports whether the compiler is the version required by Asan. -func compilerRequiredAsanVersion() bool { +func compilerRequiredAsanVersion(goos, goarch string) bool { compiler, err := compilerVersion() if err != nil { return false } switch compiler.name { case "gcc": + if goarch == "ppc64le" { + return compiler.major >= 9 + } return compiler.major >= 7 case "clang": return compiler.major >= 9 diff --git a/misc/cgo/testsanitizers/cshared_test.go b/misc/cgo/testsanitizers/cshared_test.go index 8fd03715a1..21b13ce4ed 100644 --- a/misc/cgo/testsanitizers/cshared_test.go +++ b/misc/cgo/testsanitizers/cshared_test.go @@ -52,6 +52,11 @@ func TestShared(t *testing.T) { t.Logf("skipping %s test on %s/%s; -msan option is not supported.", name, GOOS, GOARCH) continue } + if tc.sanitizer == "thread" && !compilerRequiredTsanVersion(GOOS, GOARCH) { + t.Logf("skipping %s test on %s/%s; compiler version too old for -tsan.", name, GOOS, GOARCH) + continue + } + t.Run(name, func(t *testing.T) { t.Parallel() config := configure(tc.sanitizer) diff --git a/misc/cgo/testsanitizers/tsan_test.go b/misc/cgo/testsanitizers/tsan_test.go index ec4e0033fb..00ad313b9c 100644 --- a/misc/cgo/testsanitizers/tsan_test.go +++ b/misc/cgo/testsanitizers/tsan_test.go @@ -10,6 +10,19 @@ import ( ) func TestTSAN(t *testing.T) { + goos, err := goEnv("GOOS") + if err != nil { + t.Fatal(err) + } + goarch, err := goEnv("GOARCH") + if err != nil { + t.Fatal(err) + } + // The msan tests require support for the -msan option. + if !compilerRequiredTsanVersion(goos, goarch) { + t.Skipf("skipping on %s/%s; compiler version for -tsan option is too old.", goos, goarch) + } + t.Parallel() requireOvercommit(t) config := configure("thread") |