From 5043f8c902e5ca578fbf2f0e077ec483aae4a1be Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 30 Aug 2024 09:58:22 +0200 Subject: tools/syz-kconf: fix non-determinism Currenlty we are getting random flakes in the resulting config b/c the last section (with all "is not set" configs) is unordered. This somehow affects olddefconfig and it produces random results. --- tools/syz-kconf/kconf.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/syz-kconf/kconf.go b/tools/syz-kconf/kconf.go index aea31b55c..ce39cd66a 100644 --- a/tools/syz-kconf/kconf.go +++ b/tools/syz-kconf/kconf.go @@ -13,6 +13,7 @@ import ( "path/filepath" "regexp" "runtime" + "sort" "strconv" "strings" "time" @@ -204,11 +205,17 @@ func (ctx *Context) generate() error { } // Set all configs that are not present (actually not present, rather than "is not set") to "is not set". // This avoids olddefconfig turning on random things we did not ask for. + var missing []string for _, cfg := range ctx.Kconf.Configs { if (cfg.Type == kconfig.TypeTristate || cfg.Type == kconfig.TypeBool) && cf.Map[cfg.Name] == nil { - cf.Set(cfg.Name, kconfig.No) + missing = append(missing, cfg.Name) } } + // Without sorting we can get random changes in the config after olddefconfig. + sort.Strings(missing) + for _, name := range missing { + cf.Set(name, kconfig.No) + } original := cf.Serialize() if err := osutil.WriteFile(configFile, original); err != nil { return fmt.Errorf("failed to write .config file: %w", err) -- cgit mrf-deployment