fuzz: makes execution order deterministic (#1850)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@@ -275,8 +276,16 @@ const valueTypeVector = 0x7b
|
|||||||
func ensureInvocationResultMatch(compiledMod, interpreterMod api.Module, exportedFunctions map[string]api.FunctionDefinition) (err error) {
|
func ensureInvocationResultMatch(compiledMod, interpreterMod api.Module, exportedFunctions map[string]api.FunctionDefinition) (err error) {
|
||||||
ctx := context.Background()
|
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:
|
outer:
|
||||||
for name, def := range exportedFunctions {
|
for _, name := range names {
|
||||||
|
def := exportedFunctions[name]
|
||||||
resultTypes := def.ResultTypes()
|
resultTypes := def.ResultTypes()
|
||||||
for _, rt := range resultTypes {
|
for _, rt := range resultTypes {
|
||||||
switch rt {
|
switch rt {
|
||||||
|
|||||||
Reference in New Issue
Block a user