mirror of
https://github.com/mjl-/mox.git
synced 2024-12-25 16:03:48 +03:00
5b20cba50a
we don't want external software to include internal details like mlog. slog.Logger is/will be the standard. we still have mlog for its helper functions, and its handler that logs in concise logfmt used by mox. packages that are not meant for reuse still pass around mlog.Log for convenience. we use golang.org/x/exp/slog because we also support the previous Go toolchain version. with the next Go release, we'll switch to the builtin slog.
37 lines
859 B
Go
37 lines
859 B
Go
package junk
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/mjl-/mox/mlog"
|
|
)
|
|
|
|
func FuzzParseMessage(f *testing.F) {
|
|
f.Add("")
|
|
add := func(p string) {
|
|
buf, err := os.ReadFile(p)
|
|
if err != nil {
|
|
f.Fatalf("reading file %q: %v", p, err)
|
|
}
|
|
f.Add(string(buf))
|
|
}
|
|
add(filepath.FromSlash("../testdata/junk/parse.eml"))
|
|
add(filepath.FromSlash("../testdata/junk/parse2.eml"))
|
|
add(filepath.FromSlash("../testdata/junk/parse3.eml"))
|
|
|
|
dbPath := filepath.FromSlash("../testdata/junk/parse.db")
|
|
bloomPath := filepath.FromSlash("../testdata/junk/parse.bloom")
|
|
os.Remove(dbPath)
|
|
os.Remove(bloomPath)
|
|
params := Params{Twograms: true}
|
|
log := mlog.New("junk", nil)
|
|
jf, err := NewFilter(ctxbg, log, params, dbPath, bloomPath)
|
|
if err != nil {
|
|
f.Fatalf("new filter: %v", err)
|
|
}
|
|
f.Fuzz(func(t *testing.T, s string) {
|
|
jf.tokenizeMail(s)
|
|
})
|
|
}
|