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

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

Issue 1565693002: WASM: Reserve an ignored section for source code meta information. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix some mis-uses of EXPECT_FAILURE to resolve memory leaks in the tests. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4505ba8f51d7427e4305354a2227f74d9d154d67..0738b5909ba21eefab237669041ee20d016ed195 100644
--- a/test/unittests/wasm/module-decoder-unittest.cc
+++ b/test/unittests/wasm/module-decoder-unittest.cc
@@ -878,6 +878,80 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {
if (result.val) delete result.val;
}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionNoLen) {
+ const byte data[] = {
+ kDeclWLL, // section without length.
+ };
+ EXPECT_FAILURE(data);
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionEmpty) {
+ const byte data[] = {
+ kDeclWLL, 0, // empty section
+ };
+ ModuleResult result = DecodeModule(data, data + arraysize(data));
+ EXPECT_TRUE(result.ok());
+ if (result.val) delete result.val;
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionOne) {
+ const byte data[] = {
+ kDeclWLL,
+ 1, // LEB128 1
+ 0, // one byte section
+ };
+ ModuleResult result = DecodeModule(data, data + arraysize(data));
+ EXPECT_TRUE(result.ok());
+ if (result.val) delete result.val;
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionTen) {
+ const byte data[] = {
+ kDeclWLL,
+ 10, // LEB128 10
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
+ };
+ ModuleResult result = DecodeModule(data, data + arraysize(data));
+ EXPECT_TRUE(result.ok());
+ if (result.val) delete result.val;
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionOverflow) {
+ const byte data[] = {
+ kDeclWLL,
+ 11, // LEB128 11
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
+ };
+ EXPECT_FAILURE(data);
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionUnderflow) {
+ const byte data[] = {
+ kDeclWLL,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xffffffff
+ 1, 2, 3, 4, // 4 byte section
+ };
+ EXPECT_FAILURE(data);
+}
+
+
+TEST_F(WasmModuleVerifyTest, WLLSectionLoop) {
+ // Would infinite loop decoding if wrapping and allowed.
+ const byte data[] = {
+ kDeclWLL,
+ 0xfa, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xfffffffa
+ 1, 2, 3, 4, // 4 byte section
+ };
+ EXPECT_FAILURE(data);
+}
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-module.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698