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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 EXPECT_EQ(0, function->local_i64_count); | 381 EXPECT_EQ(0, function->local_i64_count); |
382 EXPECT_EQ(0, function->local_f32_count); | 382 EXPECT_EQ(0, function->local_f32_count); |
383 EXPECT_EQ(0, function->local_f64_count); | 383 EXPECT_EQ(0, function->local_f64_count); |
384 | 384 |
385 EXPECT_FALSE(function->exported); | 385 EXPECT_FALSE(function->exported); |
386 EXPECT_TRUE(function->external); | 386 EXPECT_TRUE(function->external); |
387 | 387 |
388 if (result.val) delete result.val; | 388 if (result.val) delete result.val; |
389 } | 389 } |
390 | 390 |
391 | |
392 TEST_F(WasmModuleVerifyTest, OneFunctionWithNopBody) { | 391 TEST_F(WasmModuleVerifyTest, OneFunctionWithNopBody) { |
393 static const byte kCodeStartOffset = 19; | 392 static const byte kCodeStartOffset = 19; |
394 static const byte kCodeEndOffset = kCodeStartOffset + 1; | 393 static const byte kCodeEndOffset = kCodeStartOffset + 1; |
395 | 394 |
396 static const byte data[] = { | 395 static const byte data[] = { |
397 kDeclSignatures, 1, | 396 kDeclSignatures, 1, |
398 // sig#0 ------------------------------------------------------- | 397 // sig#0 ------------------------------------------------------- |
399 0, 0, // void -> void | 398 0, 0, // void -> void |
400 kDeclFunctions, 1, | 399 kDeclFunctions, 1, |
401 // func#0 ------------------------------------------------------ | 400 // func#0 ------------------------------------------------------ |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 VOID_VOID_SIG, | 1087 VOID_VOID_SIG, |
1089 kDeclImportTable, | 1088 kDeclImportTable, |
1090 1, // -- | 1089 1, // -- |
1091 SIG_INDEX(0), // sig index | 1090 SIG_INDEX(0), // sig index |
1092 NAME_OFFSET(1), // module name | 1091 NAME_OFFSET(1), // module name |
1093 NAME_OFFSET(1) // function name | 1092 NAME_OFFSET(1) // function name |
1094 }; | 1093 }; |
1095 EXPECT_VERIFIES(data); | 1094 EXPECT_VERIFIES(data); |
1096 } | 1095 } |
1097 | 1096 |
| 1097 TEST_F(WasmModuleVerifyTest, ImportTable_invalid_module) { |
| 1098 static const byte data[] = { |
| 1099 kDeclSignatures, |
| 1100 1, |
| 1101 VOID_VOID_SIG, |
| 1102 kDeclImportTable, |
| 1103 1, // -- |
| 1104 SIG_INDEX(0), // sig index |
| 1105 NAME_OFFSET(0), // module name |
| 1106 NAME_OFFSET(1) // function name |
| 1107 }; |
| 1108 EXPECT_FAILURE(data); |
| 1109 } |
| 1110 |
1098 TEST_F(WasmModuleVerifyTest, ImportTable_off_end) { | 1111 TEST_F(WasmModuleVerifyTest, ImportTable_off_end) { |
1099 static const byte data[] = { | 1112 static const byte data[] = { |
1100 kDeclSignatures, 1, VOID_VOID_SIG, kDeclImportTable, 1, | 1113 kDeclSignatures, 1, VOID_VOID_SIG, kDeclImportTable, 1, |
1101 SIG_INDEX(0), // sig index | 1114 SIG_INDEX(0), // sig index |
1102 NAME_OFFSET(1), // module name | 1115 NAME_OFFSET(1), // module name |
1103 NAME_OFFSET(1), // function name | 1116 NAME_OFFSET(1), // function name |
1104 }; | 1117 }; |
1105 | 1118 |
1106 EXPECT_OFF_END_FAILURE(data, 5, sizeof(data)); | 1119 EXPECT_OFF_END_FAILURE(data, 5, sizeof(data)); |
1107 } | 1120 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 for (int length = 13; length < sizeof(data); length++) { | 1218 for (int length = 13; length < sizeof(data); length++) { |
1206 ModuleResult result = DecodeModule(data, data + length); | 1219 ModuleResult result = DecodeModule(data, data + length); |
1207 EXPECT_FALSE(result.ok()); | 1220 EXPECT_FALSE(result.ok()); |
1208 if (result.val) delete result.val; | 1221 if (result.val) delete result.val; |
1209 } | 1222 } |
1210 } | 1223 } |
1211 | 1224 |
1212 } // namespace wasm | 1225 } // namespace wasm |
1213 } // namespace internal | 1226 } // namespace internal |
1214 } // namespace v8 | 1227 } // namespace v8 |
OLD | NEW |