1package junk
2
3import (
4 "os"
5 "path/filepath"
6 "testing"
7
8 "github.com/mjl-/mox/mlog"
9)
10
11func FuzzParseMessage(f *testing.F) {
12 f.Add("")
13 add := func(p string) {
14 buf, err := os.ReadFile(p)
15 if err != nil {
16 f.Fatalf("reading file %q: %v", p, err)
17 }
18 f.Add(string(buf))
19 }
20 add(filepath.FromSlash("../testdata/junk/parse.eml"))
21 add(filepath.FromSlash("../testdata/junk/parse2.eml"))
22 add(filepath.FromSlash("../testdata/junk/parse3.eml"))
23
24 dbPath := filepath.FromSlash("../testdata/junk/parse.db")
25 bloomPath := filepath.FromSlash("../testdata/junk/parse.bloom")
26 os.Remove(dbPath)
27 os.Remove(bloomPath)
28 params := Params{Twograms: true}
29 log := mlog.New("junk", nil)
30 jf, err := NewFilter(ctxbg, log, params, dbPath, bloomPath)
31 if err != nil {
32 f.Fatalf("new filter: %v", err)
33 }
34 f.Fuzz(func(t *testing.T, s string) {
35 jf.tokenizeMail(s)
36 })
37}
38