aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-08-30 09:58:22 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-08-30 08:23:10 +0000
commit5043f8c902e5ca578fbf2f0e077ec483aae4a1be (patch)
treee50bd170d911953b49431075cede660483fe738e /tools
parent323d1df5b08579bd6722fb6e486677ca9a2064fc (diff)
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-kconf/kconf.go9
1 files changed, 8 insertions, 1 deletions
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)