LearnGO/go/pkg/mod/github.com/cilium/ebpf@v0.11.0/fuzz_test.go
2024-09-19 21:38:24 -04:00

26 lines
453 B
Go

package ebpf
import (
"bytes"
"debug/elf"
"testing"
)
func FuzzLoadCollectionSpec(f *testing.F) {
f.Add([]byte(elf.ELFMAG))
f.Fuzz(func(t *testing.T, data []byte) {
if len(data) < len(elf.ELFMAG) {
t.Skip("input can't be valid ELF")
}
spec, err := LoadCollectionSpecFromReader(bytes.NewReader(data))
if err != nil {
if spec != nil {
t.Fatal("spec is not nil")
}
} else if spec == nil {
t.Fatal("spec is nil")
}
})
}