Skip to content

Commit

Permalink
fuzz: makes execution order deterministic (tetratelabs#1850)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Nov 27, 2023
1 parent 9ec7256 commit d39d845
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/integration_test/fuzz/wazerolib/nodiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"reflect"
"sort"
"strings"
"unsafe"

Expand Down Expand Up @@ -275,8 +276,16 @@ const valueTypeVector = 0x7b
func ensureInvocationResultMatch(compiledMod, interpreterMod api.Module, exportedFunctions map[string]api.FunctionDefinition) (err error) {
ctx := context.Background()

// In order to do the deterministic execution, we need to sort the exported functions.
var names []string
for f := range exportedFunctions {
names = append(names, f)
}
sort.Strings(names)

outer:
for name, def := range exportedFunctions {
for _, name := range names {
def := exportedFunctions[name]
resultTypes := def.ResultTypes()
for _, rt := range resultTypes {
switch rt {
Expand Down

0 comments on commit d39d845

Please sign in to comment.