github.com/kubeshark/ebpf@v0.9.2/fuzz_test.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package ebpf 5 6 import ( 7 "bytes" 8 "debug/elf" 9 "testing" 10 ) 11 12 func FuzzLoadCollectionSpec(f *testing.F) { 13 f.Add([]byte(elf.ELFMAG)) 14 f.Fuzz(func(t *testing.T, data []byte) { 15 if len(data) < len(elf.ELFMAG) { 16 t.Skip("input can't be valid ELF") 17 } 18 19 spec, err := LoadCollectionSpecFromReader(bytes.NewReader(data)) 20 if err != nil { 21 if spec != nil { 22 t.Fatal("spec is not nil") 23 } 24 } else if spec == nil { 25 t.Fatal("spec is nil") 26 } 27 }) 28 }