OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
6 | 6 |
7 #include "src/wasm/module-decoder.h" | 7 #include "src/wasm/module-decoder.h" |
8 #include "src/wasm/wasm-macro-gen.h" | 8 #include "src/wasm/wasm-macro-gen.h" |
9 #include "src/wasm/wasm-opcodes.h" | 9 #include "src/wasm/wasm-opcodes.h" |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 EXPECT_EQ(MachineType::Int32(), global->type); | 194 EXPECT_EQ(MachineType::Int32(), global->type); |
195 EXPECT_EQ(0, global->offset); | 195 EXPECT_EQ(0, global->offset); |
196 EXPECT_FALSE(global->exported); | 196 EXPECT_FALSE(global->exported); |
197 | 197 |
198 if (result.val) delete result.val; | 198 if (result.val) delete result.val; |
199 } | 199 } |
200 | 200 |
201 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); | 201 EXPECT_OFF_END_FAILURE(data, 1, sizeof(data)); |
202 } | 202 } |
203 | 203 |
| 204 TEST_F(WasmModuleVerifyTest, Global_invalid_type) { |
| 205 static const byte data[] = { |
| 206 SECTION(GLOBALS, 5), // -- |
| 207 1, |
| 208 NAME_LENGTH(1), |
| 209 'g', // name |
| 210 64, // invalid memory type |
| 211 0, // exported |
| 212 }; |
| 213 |
| 214 ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data)); |
| 215 EXPECT_FALSE(result.ok()); |
| 216 if (result.val) delete result.val; |
| 217 } |
| 218 |
204 TEST_F(WasmModuleVerifyTest, ZeroGlobals) { | 219 TEST_F(WasmModuleVerifyTest, ZeroGlobals) { |
205 static const byte data[] = { | 220 static const byte data[] = { |
206 SECTION(GLOBALS, 1), // -- | 221 SECTION(GLOBALS, 1), // -- |
207 0, // declare 0 globals | 222 0, // declare 0 globals |
208 }; | 223 }; |
209 ModuleResult result = DecodeModule(data, data + arraysize(data)); | 224 ModuleResult result = DecodeModule(data, data + arraysize(data)); |
210 EXPECT_OK(result); | 225 EXPECT_OK(result); |
211 if (result.val) delete result.val; | 226 if (result.val) delete result.val; |
212 } | 227 } |
213 | 228 |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 NO_LOCAL_NAMES, // -- | 1200 NO_LOCAL_NAMES, // -- |
1186 FOO_STRING, | 1201 FOO_STRING, |
1187 NO_LOCAL_NAMES, // -- | 1202 NO_LOCAL_NAMES, // -- |
1188 }; | 1203 }; |
1189 EXPECT_VERIFIES(data); | 1204 EXPECT_VERIFIES(data); |
1190 } | 1205 } |
1191 | 1206 |
1192 } // namespace wasm | 1207 } // namespace wasm |
1193 } // namespace internal | 1208 } // namespace internal |
1194 } // namespace v8 | 1209 } // namespace v8 |
OLD | NEW |