test: oss-fuzz support for fuzzing

Signed-off-by: Arjun Singh <ajsinghyadav00@gmail.com>
This commit is contained in:
Arjun Singh
2023-05-12 17:58:37 +05:30
committed by Leander Beernaert
parent cfca429067
commit cb8174dbfd
4 changed files with 92 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package parser
import (
"bytes"
"io"
"os"
"path/filepath"
@ -50,3 +51,18 @@ func getFileAsString(filename string) string {
return string(b)
}
func FuzzNewParser(f *testing.F) {
inSeed1, err1 := os.ReadFile(filepath.Join("testdata", "text_html_octet_attachment.eml"))
inSeed2, err2 := os.ReadFile(filepath.Join("testdata", "complex_structure.eml"))
require.NoError(f, err1)
require.NoError(f, err2)
f.Add(inSeed1)
f.Add(inSeed2)
f.Fuzz(func(t *testing.T, data []byte) {
_, _ = New(bytes.NewReader(data))
})
}