From 2c929d6f4c8fcd1021dc3cd57b2eedff5ae9a592 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 22 Jan 2025 17:18:19 -0500 Subject: runtime: pass through -asan/-msan/-race to testprog tests The tests using testprog / testprogcgo are currently not covered on the asan/msan/race builders because they don't build testprog with the sanitizer flag. Explicitly pass the flag if the test itself is built with the sanitizer. There were a few tests that explicitly passed -race (even on non-race builders). These tests will now only run on race builders. For #71395. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15,gotip-linux-amd64-race Change-Id: I6a6a636ce8271246316a80d426c0e4e2f6ab99c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/643897 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Auto-Submit: Michael Pratt --- src/internal/testenv/testenv.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/internal') diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index ac65ce53fb..0f6c9bbdad 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -335,13 +335,27 @@ func CanInternalLink(withCgo bool) bool { return !platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, withCgo) } +// SpecialBuildTypes are interesting build types that may affect linking. +type SpecialBuildTypes struct { + Cgo bool + Asan bool + Msan bool + Race bool +} + +// NoSpecialBuildTypes indicates a standard, no cgo go build. +var NoSpecialBuildTypes SpecialBuildTypes + // MustInternalLink checks that the current system can link programs with internal // linking. // If not, MustInternalLink calls t.Skip with an explanation. -func MustInternalLink(t testing.TB, withCgo bool) { - if !CanInternalLink(withCgo) { +func MustInternalLink(t testing.TB, with SpecialBuildTypes) { + if with.Asan || with.Msan || with.Race { + t.Skipf("skipping test: internal linking with sanitizers is not supported") + } + if !CanInternalLink(with.Cgo) { t.Helper() - if withCgo && CanInternalLink(false) { + if with.Cgo && CanInternalLink(false) { t.Skipf("skipping test: internal linking on %s/%s is not supported with cgo", runtime.GOOS, runtime.GOARCH) } t.Skipf("skipping test: internal linking on %s/%s is not supported", runtime.GOOS, runtime.GOARCH) -- cgit v1.3-5-g9baa