]> Cypherpunks repositories - gostls13.git/commitdiff
internal/trace: run children in race mode during race testing
authorMichael Pratt <mpratt@google.com>
Fri, 9 Feb 2024 19:06:39 +0000 (14:06 -0500)
committerGopher Robot <gobot@golang.org>
Fri, 9 Feb 2024 20:17:00 +0000 (20:17 +0000)
This would have caught #65607.

On my machine:

internal/trace/v2:               ~13s
internal/trace/v2: -short:        ~4s
internal/trace/v2: -race -short: ~20s
internal/trace/v2: -race:        ~46s

For #65607.

Change-Id: I03a555ebaf8c761c98a82b6d35fa16d7a99aa9e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/562998
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/internal/trace/v2/trace_test.go

index 7cc7508fe985b952bb3746b9542d0b75d70158e9..aff57d809f0fda316a72946da9032dddff2b9b2d 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bufio"
        "bytes"
        "fmt"
+       "internal/race"
        "internal/testenv"
        "internal/trace/v2"
        "internal/trace/v2/testtrace"
@@ -541,7 +542,11 @@ func testTraceProg(t *testing.T, progName string, extra func(t *testing.T, trace
        testName := progName
        runTest := func(t *testing.T, stress bool) {
                // Run the program and capture the trace, which is always written to stdout.
-               cmd := testenv.Command(t, testenv.GoToolPath(t), "run", testPath)
+               cmd := testenv.Command(t, testenv.GoToolPath(t), "run")
+               if race.Enabled {
+                       cmd.Args = append(cmd.Args, "-race")
+               }
+               cmd.Args = append(cmd.Args, testPath)
                cmd.Env = append(os.Environ(), "GOEXPERIMENT=exectracer2")
                if stress {
                        // Advance a generation constantly.