Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/unittests/wasm/module-decoder-unittest.cc

Issue 1695233002: wasm - replace the WLL section with support to skip all unknown sections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-opcodes.h" 8 #include "src/wasm/wasm-opcodes.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 EXPECT_EQ(5, function->local_f32_count); 929 EXPECT_EQ(5, function->local_f32_count);
930 EXPECT_EQ(6, function->local_f64_count); 930 EXPECT_EQ(6, function->local_f64_count);
931 EXPECT_FALSE(function->external); 931 EXPECT_FALSE(function->external);
932 EXPECT_FALSE(function->exported); 932 EXPECT_FALSE(function->exported);
933 } 933 }
934 934
935 if (result.val) delete result.val; 935 if (result.val) delete result.val;
936 } 936 }
937 937
938 938
939 TEST_F(WasmModuleVerifyTest, WLLSectionNoLen) { 939 TEST_F(WasmModuleVerifyTest, SkipSectionNoLen) {
940 const byte data[] = { 940 const byte data[] = {
941 kDeclWLL, // section without length. 941 0x5e, // misc section without length.
942 }; 942 };
943 EXPECT_FAILURE(data); 943 EXPECT_FAILURE(data);
944 } 944 }
945 945
946 946
947 TEST_F(WasmModuleVerifyTest, WLLSectionEmpty) { 947 TEST_F(WasmModuleVerifyTest, SkipSectionEmpty) {
948 static const byte data[] = { 948 static const byte data[] = {
949 kDeclWLL, 0, // empty section 949 0x5e, U32_LE(0), // misc empty section
950 }; 950 };
951 ModuleResult result = DecodeModule(data, data + arraysize(data)); 951 ModuleResult result = DecodeModule(data, data + arraysize(data));
952 EXPECT_TRUE(result.ok()); 952 EXPECT_TRUE(result.ok());
953 if (result.val) delete result.val; 953 if (result.val) delete result.val;
954 } 954 }
955 955
956 956
957 TEST_F(WasmModuleVerifyTest, WLLSectionOne) { 957 TEST_F(WasmModuleVerifyTest, SkipSectionOne) {
958 static const byte data[] = { 958 static const byte data[] = {
959 kDeclWLL, 959 0x5e, // misc section
960 1, // LEB128 1 960 U32_LE(1),
961 0, // one byte section 961 0, // one byte section
962 }; 962 };
963 ModuleResult result = DecodeModule(data, data + arraysize(data)); 963 ModuleResult result = DecodeModule(data, data + arraysize(data));
964 EXPECT_TRUE(result.ok()); 964 EXPECT_TRUE(result.ok());
965 if (result.val) delete result.val; 965 if (result.val) delete result.val;
966 } 966 }
967 967
968 968
969 TEST_F(WasmModuleVerifyTest, WLLSectionTen) { 969 TEST_F(WasmModuleVerifyTest, SkipSectionTen) {
970 static const byte data[] = { 970 static const byte data[] = {
971 kDeclWLL, 971 0x5e,
972 10, // LEB128 10 972 U32_LE(10),
973 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section 973 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
974 }; 974 };
975 ModuleResult result = DecodeModule(data, data + arraysize(data)); 975 ModuleResult result = DecodeModule(data, data + arraysize(data));
976 EXPECT_TRUE(result.ok()); 976 EXPECT_TRUE(result.ok());
977 if (result.val) delete result.val; 977 if (result.val) delete result.val;
978 } 978 }
979 979
980 980
981 TEST_F(WasmModuleVerifyTest, WLLSectionOverflow) { 981 TEST_F(WasmModuleVerifyTest, SkipSectionOverflow) {
982 static const byte data[] = { 982 static const byte data[] = {
983 kDeclWLL, 983 0x5e,
984 11, // LEB128 11 984 U32_LE(11),
985 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section 985 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
986 }; 986 };
987 EXPECT_FAILURE(data); 987 EXPECT_FAILURE(data);
988 } 988 }
989 989
990 990
991 TEST_F(WasmModuleVerifyTest, WLLSectionUnderflow) { 991 TEST_F(WasmModuleVerifyTest, SkipSectionUnderflow) {
992 static const byte data[] = { 992 static const byte data[] = {
993 kDeclWLL, 0xff, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xffffffff 993 0x5e,
994 1, 2, 3, 4, // 4 byte section 994 U32_LE(0xffffffff),
995 1, 2, 3, 4, // 4 byte section
995 }; 996 };
996 EXPECT_FAILURE(data); 997 EXPECT_FAILURE(data);
997 } 998 }
998 999
999 1000
1000 TEST_F(WasmModuleVerifyTest, WLLSectionLoop) { 1001 TEST_F(WasmModuleVerifyTest, SkipSectionLoop) {
1001 // Would infinite loop decoding if wrapping and allowed. 1002 // Would infinite loop decoding if wrapping and allowed.
1002 static const byte data[] = { 1003 static const byte data[] = {
1003 kDeclWLL, 0xfa, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xfffffffa 1004 0x5e,
1004 1, 2, 3, 4, // 4 byte section 1005 U32_LE(0xfffffffa),
1006 1, 2, 3, 4, // 4 byte section
1005 }; 1007 };
1006 EXPECT_FAILURE(data); 1008 EXPECT_FAILURE(data);
1007 } 1009 }
1008 1010
1009 TEST_F(WasmModuleVerifyTest, ImportTable_empty) { 1011 TEST_F(WasmModuleVerifyTest, ImportTable_empty) {
1010 static const byte data[] = {kDeclSignatures, 0, kDeclImportTable, 0}; 1012 static const byte data[] = {kDeclSignatures, 0, kDeclImportTable, 0};
1011 EXPECT_VERIFIES(data); 1013 EXPECT_VERIFIES(data);
1012 } 1014 }
1013 1015
1014 TEST_F(WasmModuleVerifyTest, ImportTable_nosigs) { 1016 TEST_F(WasmModuleVerifyTest, ImportTable_nosigs) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 for (size_t length = 5; length < sizeof(data); length++) { 1083 for (size_t length = 5; length < sizeof(data); length++) {
1082 ModuleResult result = DecodeModule(data, data + length); 1084 ModuleResult result = DecodeModule(data, data + length);
1083 EXPECT_FALSE(result.ok()); 1085 EXPECT_FALSE(result.ok());
1084 if (result.val) delete result.val; 1086 if (result.val) delete result.val;
1085 } 1087 }
1086 } 1088 }
1087 1089
1088 } // namespace wasm 1090 } // namespace wasm
1089 } // namespace internal 1091 } // namespace internal
1090 } // namespace v8 1092 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698