]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo/internal/testsanitizers: don't create fuzz corpus
authorIan Lance Taylor <iant@golang.org>
Wed, 20 Nov 2024 22:18:58 +0000 (14:18 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 21 Nov 2024 02:17:08 +0000 (02:17 +0000)
The TestASANFuzz test would sometimes create a fuzz corpus
in testdata/testdata/FuzzReverse. Avoid modifying the source
directory by building the test with "go test -c" and running
it in a temporary directory.

Change-Id: I12e2da4c85165fa35e0dc1aa6b46c6d0fbccaab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/630377
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/cmd/cgo/internal/testsanitizers/asan_test.go

index 0d819f27979a80eecf98a4980d7cf640b6abde9c..19810aafb654b17a4f2e7cfff6b3633f6630f8b4 100644 (file)
@@ -11,6 +11,7 @@ import (
        "fmt"
        "internal/platform"
        "internal/testenv"
+       "os/exec"
        "strings"
        "testing"
 )
@@ -114,10 +115,20 @@ func TestASANFuzz(t *testing.T) {
        dir := newTempDir(t)
        defer dir.RemoveAll(t)
 
-       cmd := config.goCmd("test", "-fuzz=Fuzz", srcPath("asan_fuzz_test.go"))
+       exe := dir.Join("asan_fuzz_test.exe")
+       cmd := config.goCmd("test", "-c", "-o", exe, srcPath("asan_fuzz_test.go"))
        t.Logf("%v", cmd)
        out, err := cmd.CombinedOutput()
        t.Logf("%s", out)
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       cmd = exec.Command(exe, "-test.fuzz=Fuzz", "-test.fuzzcachedir="+dir.Base())
+       cmd.Dir = dir.Base()
+       t.Logf("%v", cmd)
+       out, err = cmd.CombinedOutput()
+       t.Logf("%s", out)
        if err == nil {
                t.Error("expected fuzzing failure")
        }