cmd/dist: enable msan/asan

Supporting memory sanitizer and address sanitizer in toolchains

Change-Id: Ie292657b78954d65bd72e64e063b1c4f18d4f0d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/374974
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Meng Zhuo 2021-12-30 16:46:21 +08:00 committed by mzh
parent c4efe7fb27
commit be8ee5a58f

11
src/cmd/dist/test.go vendored
View File

@ -38,6 +38,9 @@ func cmdtest() {
flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
"run only those tests matching the regular expression; empty means to run all. "+
"Special exception: if the string begins with '!', the match is inverted.")
flag.BoolVar(&t.msan, "msan", false, "run in memory sanitizer builder mode")
flag.BoolVar(&t.asan, "asan", false, "run in address sanitizer builder mode")
xflagparse(-1) // any number of args
if noRebuild {
t.rebuild = false
@ -49,6 +52,8 @@ func cmdtest() {
// tester executes cmdtest.
type tester struct {
race bool
msan bool
asan bool
listMode bool
rebuild bool
failed bool
@ -404,6 +409,12 @@ func (t *tester) registerStdTest(pkg string) {
if t.race {
args = append(args, "-race")
}
if t.msan {
args = append(args, "-msan")
}
if t.asan {
args = append(args, "-asan")
}
if t.compileOnly {
args = append(args, "-run=^$")
}