prog: sort enabled syscalls for determinism

Makes tests deterministic and syz-mutate with -seed flag.

Pointed out by Jordan Frank (@jwf).
This commit is contained in:
Dmitry Vyukov 2020-03-06 09:01:48 +01:00
parent 850c989d4f
commit 7fb694ef82

View File

@ -221,6 +221,9 @@ func (target *Target) BuildChoiceTable(prios [][]float32, enabled map[*Syscall]b
if len(enabledCalls) == 0 {
panic(fmt.Sprintf("empty enabledCalls, len(target.Syscalls)=%v", len(target.Syscalls)))
}
sort.Slice(enabledCalls, func(i, j int) bool {
return enabledCalls[i].ID < enabledCalls[j].ID
})
run := make([][]int, len(target.Syscalls))
for i := range run {
if !enabled[target.Syscalls[i]] {