From 00e684e95c44002d863beae454c8434f7e76d0fd Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 9 Feb 2024 12:20:23 -0800 Subject: [PATCH] fuzz: ensures wazerolib test running Signed-off-by: Takeshi Yoneda --- Makefile | 1 + internal/integration_test/fuzz/predicate.sh | 2 +- .../integration_test/fuzz/wazerolib/nodiff.go | 8 +++++--- .../fuzz/wazerolib/nodiff_test.go | 15 ++++++++++----- .../fuzz/wazerolib/testdata/.keep | 0 .../fuzz/wazerolib/testdata/test.wasm | Bin 0 -> 666 bytes 6 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 internal/integration_test/fuzz/wazerolib/testdata/.keep create mode 100644 internal/integration_test/fuzz/wazerolib/testdata/test.wasm diff --git a/Makefile b/Makefile index 9017050180..ec87f0bd54 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/internal/integration_test/fuzz/predicate.sh b/internal/integration_test/fuzz/predicate.sh index de376eed6e..9a1bae4fe9 100755 --- a/internal/integration_test/fuzz/predicate.sh +++ b/internal/integration_test/fuzz/predicate.sh @@ -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 $((! $?)) diff --git a/internal/integration_test/fuzz/wazerolib/nodiff.go b/internal/integration_test/fuzz/wazerolib/nodiff.go index 460f7206d2..ae20c5e410 100644 --- a/internal/integration_test/fuzz/wazerolib/nodiff.go +++ b/internal/integration_test/fuzz/wazerolib/nodiff.go @@ -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)) } } } diff --git a/internal/integration_test/fuzz/wazerolib/nodiff_test.go b/internal/integration_test/fuzz/wazerolib/nodiff_test.go index 9807f7e748..7b51f46dde 100644 --- a/internal/integration_test/fuzz/wazerolib/nodiff_test.go +++ b/internal/integration_test/fuzz/wazerolib/nodiff_test.go @@ -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", @@ -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", @@ -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", @@ -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`, }, { @@ -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) { diff --git a/internal/integration_test/fuzz/wazerolib/testdata/.keep b/internal/integration_test/fuzz/wazerolib/testdata/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/internal/integration_test/fuzz/wazerolib/testdata/test.wasm b/internal/integration_test/fuzz/wazerolib/testdata/test.wasm new file mode 100644 index 0000000000000000000000000000000000000000..c0282923b775a2930d87dc7451283837a821f5ca GIT binary patch literal 666 zcmZQbEY4+QU|?WmXG~zMXR57XW@2PulV_=8bYkGHXLMxXu4Qxv$}@1+FuH(f5a4EK z0qNno&BAztg~5?=lS>U0z!}>d8Mh-ia2A}g4aBkm=|U9(iBKxU#l_{sfPjt+&KH5e z<;Q+6pDm6(eJ=K3OKNJsZop-sbNx}HHE_4V8Ay6urKernFef|*NeE(ae?LeFVhcRX zFjOJizfFZnnQ6BQvof;+1B-()lQJ_uEB9VyhE^2@WkwZ75Z