Chromium Code Reviews| Index: test/unittests/wasm/module-decoder-unittest.cc |
| diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc |
| index baf6909499ce22679e945ea22acd2ae4a4aca622..7a29f87a7851423e224d1aefab6eef690aefe397 100644 |
| --- a/test/unittests/wasm/module-decoder-unittest.cc |
| +++ b/test/unittests/wasm/module-decoder-unittest.cc |
| @@ -7,6 +7,7 @@ |
| #include "src/handles.h" |
| #include "src/objects-inl.h" |
| #include "src/wasm/module-decoder.h" |
| +#include "src/wasm/wasm-limits.h" |
| #include "src/wasm/wasm-macro-gen.h" |
| #include "src/wasm/wasm-opcodes.h" |
| @@ -310,7 +311,7 @@ TEST_F(WasmModuleVerifyTest, NGlobals) { |
| WASM_INIT_EXPR_F32(7.7), // init |
| }; |
| - for (uint32_t i = 0; i < 1000000; i = i * 13 + 1) { |
| + for (uint32_t i = 0; i < kV8MaxWasmGlobals; i = i * 13 + 1) { |
| std::vector<byte> buffer; |
| size_t size = SizeOfVarInt(i) + i * sizeof(data); |
| const byte globals[] = {kGlobalSectionCode, U32V_5(size)}; |
| @@ -847,6 +848,31 @@ TEST_F(WasmSignatureDecodeTest, Ok_i_tt) { |
| } |
| } |
| +TEST_F(WasmSignatureDecodeTest, TooManyParams) { |
| + static const byte data[] = {kWasmFunctionTypeForm, |
| + WASM_I32V_3(kV8MaxWasmFunctionParamCount + 1), |
| + kLocalI32, 0}; |
| + FunctionSig* sig = |
| + DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); |
| + EXPECT_FALSE(sig != nullptr); |
|
Clemens Hammacher
2016/12/14 12:50:26
Double negation is hard to read IMO.
EXPECT_TRUE(s
titzer
2016/12/14 17:19:53
Done.
|
| +} |
| + |
| +TEST_F(WasmSignatureDecodeTest, TooManyReturns) { |
| + bool prev = FLAG_wasm_mv_prototype; |
| + for (int i = 0; i < 2; i++) { |
| + FLAG_wasm_mv_prototype = i != 0; |
| + const int max_return_count = static_cast<int>( |
| + FLAG_wasm_mv_prototype ? kV8MaxWasmFunctionMultiReturnCount |
| + : kV8MaxWasmFunctionReturnCount); |
| + byte data[] = {kWasmFunctionTypeForm, 0, WASM_I32V_3(max_return_count + 1), |
| + kLocalI32}; |
| + FunctionSig* sig = |
| + DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); |
| + EXPECT_FALSE(sig != nullptr); |
|
Clemens Hammacher
2016/12/14 12:50:26
Same here.
titzer
2016/12/14 17:19:53
Done.
|
| + FLAG_wasm_mv_prototype = prev; |
| + } |
| +} |
| + |
| TEST_F(WasmSignatureDecodeTest, Fail_off_end) { |
| byte data[256]; |
| for (int p = 0; p <= 255; p = p + 1 + p * 3) { |