Skip to content

Commit 6b818b0

Browse files
callthingsoffheschi
authored andcommitted
internal/zstd: use dynamic path resolution for xxhsum in FuzzXXHash
Updates #64000 Change-Id: I71fb80128d7e2a1f82322cbf04f74db01dcc631b GitHub-Last-Rev: 7413594 GitHub-Pull-Request: #64003 Reviewed-on: https://go-review.googlesource.com/c/go/+/539938 Run-TryBot: Jes Cok <[email protected]> TryBot-Result: Gopher Robot <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent bea5513 commit 6b818b0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/internal/zstd/xxhash_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,16 @@ func TestLargeXXHash(t *testing.T) {
6767
}
6868
}
6969

70-
func FuzzXXHash(f *testing.F) {
71-
if _, err := os.Stat("/usr/bin/xxhsum"); err != nil {
72-
f.Skip("skipping because /usr/bin/xxhsum does not exist")
70+
func findXxhsum(t testing.TB) string {
71+
xxhsum, err := exec.LookPath("xxhsum")
72+
if err != nil {
73+
t.Skip("skipping because xxhsum not found")
7374
}
75+
return xxhsum
76+
}
77+
78+
func FuzzXXHash(f *testing.F) {
79+
xxhsum := findXxhsum(f)
7480

7581
for _, test := range xxHashTests {
7682
f.Add([]byte(test.data))
@@ -84,7 +90,7 @@ func FuzzXXHash(f *testing.F) {
8490
f.Add(bigData(f))
8591

8692
f.Fuzz(func(t *testing.T, b []byte) {
87-
cmd := exec.Command("/usr/bin/xxhsum", "-H64")
93+
cmd := exec.Command(xxhsum, "-H64")
8894
cmd.Stdin = bytes.NewReader(b)
8995
var hhsumHash bytes.Buffer
9096
cmd.Stdout = &hhsumHash

0 commit comments

Comments
 (0)