diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-17 16:39:02 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-17 17:50:02 +0100 |
| commit | 7eca15bf0a08747c3f79445ca59ed86eb1ced4fd (patch) | |
| tree | 6b4450b54a8747886b00df33ed04e60741b71d54 /pkg/kconfig/minimize.go | |
| parent | bd2a760b69f2df56a20577ba8c0665105766f3bd (diff) | |
pkg/kconfig: add minimization test with dependent configs
Test for case described in:
https://groups.google.com/g/syzkaller/c/c1J1kzzW7Ew/m/CeyEJm04AQAJ
It seems to work as is (mostly).
Fix parsing of the very last kconfig config (currently it's dropped).
s/menuend/endmenu/ in error message.
Sort dependencies so that we can express the test.
But none of this should have affected actual config minimization.
Diffstat (limited to 'pkg/kconfig/minimize.go')
| -rw-r--r-- | pkg/kconfig/minimize.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/pkg/kconfig/minimize.go b/pkg/kconfig/minimize.go index 7acf2b349..bbcb95414 100644 --- a/pkg/kconfig/minimize.go +++ b/pkg/kconfig/minimize.go @@ -28,7 +28,7 @@ func (kconf *KConfig) Minimize(base, full *ConfigFile, pred func(*ConfigFile) (b } // Since base does not crash, full config is our best bet for now. current := full.clone() - var suspects map[string]bool + var suspects []string // Take half of the diff between base and full, apply to base and test. // If this candidate config crashes, we commit it as new full and repeat the process. // If it does not crash, try another half. @@ -48,11 +48,11 @@ top: trace.log("trying half: %v", part) closure := kconf.addDependencies(base, full, part) candidate := base.clone() - // 1. Always move all non-tristate configs from full to base as we don't minimize them. + // Always move all non-tristate configs from full to base as we don't minimize them. for _, cfg := range other { candidate.Set(cfg.Name, cfg.Value) } - for cfg := range closure { + for _, cfg := range closure { candidate.Set(cfg, Yes) } res, err := pred(candidate) @@ -90,7 +90,7 @@ func (kconf *KConfig) missingConfigs(base, full *ConfigFile) (tristate []string, return } -func (kconf *KConfig) addDependencies(base, full *ConfigFile, configs []string) map[string]bool { +func (kconf *KConfig) addDependencies(base, full *ConfigFile, configs []string) []string { closure := make(map[string]bool) for _, cfg := range configs { closure[cfg] = true @@ -102,7 +102,12 @@ func (kconf *KConfig) addDependencies(base, full *ConfigFile, configs []string) } } } - return closure + var sorted []string + for cfg := range closure { + sorted = append(sorted, cfg) + } + sort.Strings(sorted) + return sorted } type traceLogger struct{ io.Writer } |
