Skip to content

Commit

Permalink
fuzz: ensures wazerolib test running
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake committed Feb 9, 2024
1 parent 25cf3c0 commit 00e684e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ build.spectest.threads:
test:
@go test $(go_test_options) $$(go list ./... | grep -vE '$(spectest_v1_dir)|$(spectest_v2_dir)')
@cd internal/version/testdata && go test $(go_test_options) ./...
@cd internal/integration_test/fuzz/wazerolib && WASM_BINARY_PATH=testdata/test.wasm go test $(go_test_options) ./...

.PHONY: coverage
# replace spaces with commas
Expand Down
2 changes: 1 addition & 1 deletion internal/integration_test/fuzz/predicate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo "Testing $WASM"
export WASM_BINARY_PATH=$WASM

# Run the test and reverse the exit code so that a non-zero exit code indicates interesting case.
./nodiff.test
./nodiff.test -test.run=TestReRunFailedRequireNoDiffCase
exit $((! $?))
8 changes: 5 additions & 3 deletions internal/integration_test/fuzz/wazerolib/nodiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ func ensureMutableGlobalsMatch(compilerMod, interpreterMod api.Module, requireNo
}

if !ok {
if ig.Type.ValType == wasm.ValueTypeV128 {
es = append(es, fmt.Sprintf("mutable global[%d] value mismatch: (%v,%v) != (%v,%v)", i, cVal, cValHi, iVal, iValHi))
if typ := ig.Type.ValType; typ == wasm.ValueTypeV128 {
es = append(es, fmt.Sprintf("\t[%d] %s: (%v,%v) != (%v,%v)",
i, wasm.ValueTypeName(wasm.ValueTypeV128), cVal, cValHi, iVal, iValHi))
} else {
es = append(es, fmt.Sprintf("mutable global[%d] value mismatch: %v != %v", i, cVal, iVal))
es = append(es, fmt.Sprintf("\t[%d] %s: %v != %v",
i, wasm.ValueTypeName(typ), cVal, iVal))
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions internal/integration_test/fuzz/wazerolib/nodiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func Test_ensureMutableGlobalsMatch(t *testing.T) {
{Val: 11, Type: wasm.GlobalType{Mutable: true, ValType: wasm.ValueTypeI32}},
},
},
expErr: "mutable global[1] value mismatch: 10 != 11",
expErr: `mutable globals mismatch:
[1] i32: 10 != 11`,
},
{
name: "i64 match",
Expand Down Expand Up @@ -93,7 +94,8 @@ func Test_ensureMutableGlobalsMatch(t *testing.T) {
{Val: 1 << 63, Type: wasm.GlobalType{Mutable: true, ValType: wasm.ValueTypeI64}},
},
},
expErr: "mutable global[2] value mismatch: 4611686018427387904 != 9223372036854775808",
expErr: `mutable globals mismatch:
[2] i64: 4611686018427387904 != 9223372036854775808`,
},
{
name: "f32 match",
Expand Down Expand Up @@ -124,7 +126,8 @@ func Test_ensureMutableGlobalsMatch(t *testing.T) {
{Val: 11, Type: wasm.GlobalType{Mutable: true, ValType: wasm.ValueTypeF32}},
},
},
expErr: "mutable global[1] value mismatch: 10 != 11",
expErr: `mutable globals mismatch:
[1] f32: 10 != 11`,
},
{
name: "f64 match",
Expand Down Expand Up @@ -157,7 +160,8 @@ func Test_ensureMutableGlobalsMatch(t *testing.T) {
{Val: 1 << 63, Type: wasm.GlobalType{Mutable: true, ValType: wasm.ValueTypeF64}},
},
},
expErr: "mutable global[2] value mismatch: 4611686018427387904 != 9223372036854775808",
expErr: `mutable globals mismatch:
[2] f64: 4611686018427387904 != 9223372036854775808`,
},

{
Expand Down Expand Up @@ -191,7 +195,8 @@ func Test_ensureMutableGlobalsMatch(t *testing.T) {
{Val: 1 << 62, ValHi: 1234, Type: wasm.GlobalType{Mutable: true, ValType: wasm.ValueTypeV128}},
},
},
expErr: "mutable global[2] value mismatch: (4611686018427387904,0) != (4611686018427387904,1234)",
expErr: `mutable globals mismatch:
[2] v128: (4611686018427387904,0) != (4611686018427387904,1234)`,
},
} {
t.Run(tc.name, func(t *testing.T) {
Expand Down
Empty file.
Binary file not shown.

0 comments on commit 00e684e

Please sign in to comment.