On baremetal platforms, use simpler test matcher. Fixes #2666.

Uses same matcher in testdata (because now we can't replace it in testdata).
This commit is contained in:
Dan Kegel
2022-03-13 12:27:44 -07:00
committed by Ron Evans
parent eed78338e6
commit c534fa1b6f
5 changed files with 47 additions and 11 deletions
+16
View File
@@ -26,6 +26,11 @@ type matcher struct {
var matchMutex sync.Mutex
func newMatcher(matchString func(pat, str string) (bool, error), patterns, name string) *matcher {
if isBaremetal {
// Probably not enough ram to load regexp, substitute something simpler.
matchString = fakeMatchString
}
var filter []string
if patterns != "" {
filter = splitRegexp(patterns)
@@ -166,3 +171,14 @@ func isSpace(r rune) bool {
}
return false
}
// A fake regexp matcher.
// Inflexible, but saves 50KB of flash and 50KB of RAM per -size full,
// and lets tests pass on cortex-m.
func fakeMatchString(pat, str string) (bool, error) {
if pat == ".*" {
return true, nil
}
matched := strings.Contains(str, pat)
return matched, nil
}