mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 02:31:18 -08:00
Prior to this change there were two problems with our fuzzing for oss-fuzz: 1. There was an issue if the fuzzing spanned two files (mingled with the testing). 2. The fuzzing needs to be part of the implementation package (no _test packages). This change fixes that by moving all package fuzzing into a common `fuzz_test.go` within the package. Updates https://github.com/tailscale/corp/issues/46608 Change-Id: I0b95edcd0df946f723eea32f575c679214c0b202 Signed-off-by: Mike Jensen <[email protected]>
26 lines
530 B
Go
26 lines
530 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package safediff
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func FuzzDiff(f *testing.F) {
|
|
f.Fuzz(func(t *testing.T, x, y string, maxSize int) {
|
|
const maxInput = 1e3
|
|
if len(x) > maxInput {
|
|
x = x[:maxInput]
|
|
}
|
|
if len(y) > maxInput {
|
|
y = y[:maxInput]
|
|
}
|
|
diff, _ := Lines(x, y, maxSize) // make sure this does not panic
|
|
if strings.Count(diff, "\n") > 1 && maxSize >= 0 && len(diff) > maxSize {
|
|
t.Fatal("maxSize exceeded")
|
|
}
|
|
})
|
|
}
|