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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.h ('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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 EXPECT_EQ(3, function->local_int32_count); 871 EXPECT_EQ(3, function->local_int32_count);
872 EXPECT_EQ(4, function->local_int64_count); 872 EXPECT_EQ(4, function->local_int64_count);
873 EXPECT_EQ(5, function->local_float32_count); 873 EXPECT_EQ(5, function->local_float32_count);
874 EXPECT_EQ(6, function->local_float64_count); 874 EXPECT_EQ(6, function->local_float64_count);
875 EXPECT_FALSE(function->external); 875 EXPECT_FALSE(function->external);
876 EXPECT_FALSE(function->exported); 876 EXPECT_FALSE(function->exported);
877 } 877 }
878 878
879 if (result.val) delete result.val; 879 if (result.val) delete result.val;
880 } 880 }
881
882
883 TEST_F(WasmModuleVerifyTest, WLLSectionNoLen) {
884 const byte data[] = {
885 kDeclWLL, // section without length.
886 };
887 EXPECT_FAILURE(data);
888 }
889
890
891 TEST_F(WasmModuleVerifyTest, WLLSectionEmpty) {
892 const byte data[] = {
893 kDeclWLL, 0, // empty section
894 };
895 ModuleResult result = DecodeModule(data, data + arraysize(data));
896 EXPECT_TRUE(result.ok());
897 if (result.val) delete result.val;
898 }
899
900
901 TEST_F(WasmModuleVerifyTest, WLLSectionOne) {
902 const byte data[] = {
903 kDeclWLL,
904 1, // LEB128 1
905 0, // one byte section
906 };
907 ModuleResult result = DecodeModule(data, data + arraysize(data));
908 EXPECT_TRUE(result.ok());
909 if (result.val) delete result.val;
910 }
911
912
913 TEST_F(WasmModuleVerifyTest, WLLSectionTen) {
914 const byte data[] = {
915 kDeclWLL,
916 10, // LEB128 10
917 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
918 };
919 ModuleResult result = DecodeModule(data, data + arraysize(data));
920 EXPECT_TRUE(result.ok());
921 if (result.val) delete result.val;
922 }
923
924
925 TEST_F(WasmModuleVerifyTest, WLLSectionOverflow) {
926 const byte data[] = {
927 kDeclWLL,
928 11, // LEB128 11
929 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // 10 byte section
930 };
931 EXPECT_FAILURE(data);
932 }
933
934
935 TEST_F(WasmModuleVerifyTest, WLLSectionUnderflow) {
936 const byte data[] = {
937 kDeclWLL,
938 0xff, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xffffffff
939 1, 2, 3, 4, // 4 byte section
940 };
941 EXPECT_FAILURE(data);
942 }
943
944
945 TEST_F(WasmModuleVerifyTest, WLLSectionLoop) {
946 // Would infinite loop decoding if wrapping and allowed.
947 const byte data[] = {
948 kDeclWLL,
949 0xfa, 0xff, 0xff, 0xff, 0x0f, // LEB128 0xfffffffa
950 1, 2, 3, 4, // 4 byte section
951 };
952 EXPECT_FAILURE(data);
953 }
954
881 } // namespace wasm 955 } // namespace wasm
882 } // namespace internal 956 } // namespace internal
883 } // namespace v8 957 } // namespace v8
OLDNEW
« 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