Chromium Code Reviews| 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 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 static const byte data[] = { | 1052 static const byte data[] = { |
| 1053 kDeclSignatures, 1, VOID_VOID_SIG, kDeclImportTable, 1, | 1053 kDeclSignatures, 1, VOID_VOID_SIG, kDeclImportTable, 1, |
| 1054 IMPORT_SIG_INDEX(0), // sig index | 1054 IMPORT_SIG_INDEX(0), // sig index |
| 1055 NAME_LENGTH(1), 'm', // module name | 1055 NAME_LENGTH(1), 'm', // module name |
| 1056 NAME_LENGTH(1), 'f', // function name | 1056 NAME_LENGTH(1), 'f', // function name |
| 1057 }; | 1057 }; |
| 1058 | 1058 |
| 1059 EXPECT_OFF_END_FAILURE(data, 5, sizeof(data)); | 1059 EXPECT_OFF_END_FAILURE(data, 5, sizeof(data)); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 TEST_F(WasmModuleVerifyTest, ExportTable_empty) { | 1062 TEST_F(WasmModuleVerifyTest, ExportTable_empty1) { |
| 1063 static const byte data[] = {kDeclSignatures, 1, VOID_VOID_SIG, | |
| 1064 kDeclFunctions, 1, EMPTY_FUNCTION(0), | |
| 1065 kDeclExportTable, 0}; | |
| 1066 EXPECT_VERIFIES(data); | |
| 1067 } | |
| 1068 | |
| 1069 TEST_F(WasmModuleVerifyTest, ExportTable_empty2) { | |
| 1063 static const byte data[] = {kDeclSignatures, 0, kDeclFunctions, 0, | 1070 static const byte data[] = {kDeclSignatures, 0, kDeclFunctions, 0, |
| 1064 kDeclExportTable, 0}; | 1071 kDeclExportTable, 0}; |
| 1065 EXPECT_VERIFIES(data); | 1072 // TODO(titzer): current behavior treats empty functions section as missing. |
|
binji
2016/03/09 22:20:17
OK, so I should emit an empty function section whe
| |
| 1073 EXPECT_FAILURE(data); | |
| 1066 } | 1074 } |
| 1067 | 1075 |
| 1068 TEST_F(WasmModuleVerifyTest, ExportTable_NoFunctions1) { | 1076 TEST_F(WasmModuleVerifyTest, ExportTable_NoFunctions1) { |
| 1069 static const byte data[] = {kDeclSignatures, 0, kDeclExportTable, 0}; | 1077 static const byte data[] = {kDeclSignatures, 0, kDeclExportTable, 0}; |
| 1070 EXPECT_FAILURE(data); | 1078 EXPECT_FAILURE(data); |
| 1071 } | 1079 } |
| 1072 | 1080 |
| 1073 TEST_F(WasmModuleVerifyTest, ExportTable_NoFunctions2) { | 1081 TEST_F(WasmModuleVerifyTest, ExportTable_NoFunctions2) { |
| 1074 static const byte data[] = {kDeclExportTable, 0}; | 1082 static const byte data[] = {kDeclExportTable, 0}; |
| 1075 EXPECT_FAILURE(data); | 1083 EXPECT_FAILURE(data); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 for (int length = 13; length < sizeof(data); length++) { | 1166 for (int length = 13; length < sizeof(data); length++) { |
| 1159 ModuleResult result = DecodeModule(data, data + length); | 1167 ModuleResult result = DecodeModule(data, data + length); |
| 1160 EXPECT_FALSE(result.ok()); | 1168 EXPECT_FALSE(result.ok()); |
| 1161 if (result.val) delete result.val; | 1169 if (result.val) delete result.val; |
| 1162 } | 1170 } |
| 1163 } | 1171 } |
| 1164 | 1172 |
| 1165 } // namespace wasm | 1173 } // namespace wasm |
| 1166 } // namespace internal | 1174 } // namespace internal |
| 1167 } // namespace v8 | 1175 } // namespace v8 |
| OLD | NEW |