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

Side by Side Diff: unittests/Bitcode/NaClParseTypesTest.cpp

Issue 932953002: Fix the NaCl bitstream reader to report fatal errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Merge with master Created 5 years, 9 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 | « unittests/Bitcode/NaClParseInstsTest.cpp ('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 //===- llvm/unittest/Bitcode/NaClParseTypesTest.cpp ---------------------===// 1 //===- llvm/unittest/Bitcode/NaClParseTypesTest.cpp ---------------------===//
2 // Tests parser for PNaCl bitcode. 2 // Tests parser for PNaCl bitcode.
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 10
(...skipping 21 matching lines...) Expand all
32 3, 3, Terminator, 32 3, 3, Terminator,
33 0, 65534, Terminator, 33 0, 65534, Terminator,
34 0, 65534, Terminator 34 0, 65534, Terminator
35 }; 35 };
36 36
37 const uint64_t ReplaceIndex = 4; 37 const uint64_t ReplaceIndex = 4;
38 38
39 // Show text of base input. 39 // Show text of base input.
40 NaClObjDumpMunger BaseMunger(BitcodeRecords, 40 NaClObjDumpMunger BaseMunger(BitcodeRecords,
41 array_lengthof(BitcodeRecords), Terminator); 41 array_lengthof(BitcodeRecords), Terminator);
42 EXPECT_TRUE(BaseMunger.runTestForAssembly("Bad type references base")); 42 EXPECT_TRUE(BaseMunger.runTest("Bad type references base"));
43 EXPECT_EQ( 43 EXPECT_EQ(
44 "module { // BlockID = 8\n" 44 " 0:0|<65532, 80, 69, 88, 69, 1, 0,|Magic Number: 'PEXE' (80, 69, "
45 " types { // BlockID = 17\n" 45 "88, 69)\n"
46 " count 2;\n" 46 " | 8, 0, 17, 0, 4, 0, 2, 0, 0, |PNaCl Version: 2\n"
47 " @t0 = i32;\n" 47 " | 0> |\n"
48 " @t1 = float;\n" 48 " 16:0|1: <65535, 8, 2> |module { // BlockID = 8\n"
49 " }\n" 49 " 24:0| 1: <65535, 17, 2> | types { // BlockID = 17\n"
50 "}\n", 50 " 32:0| 3: <1, 2> | count 2;\n"
51 " 34:4| 3: <7, 32> | @t0 = i32;\n"
52 " 37:6| 3: <3> | @t1 = float;\n"
53 " 39:4| 0: <65534> | }\n"
54 " 40:0|0: <65534> |}\n",
51 BaseMunger.getTestResults()); 55 BaseMunger.getTestResults());
52 56
53 // Show that we successfully parse the base input. 57 // Show that we successfully parse the base input.
54 NaClParseBitcodeMunger Munger(BitcodeRecords, 58 NaClParseBitcodeMunger Munger(BitcodeRecords,
55 array_lengthof(BitcodeRecords), Terminator); 59 array_lengthof(BitcodeRecords), Terminator);
56 EXPECT_TRUE(Munger.runTest("base parse", true)); 60 EXPECT_TRUE(Munger.runTest("base parse", true));
57 EXPECT_EQ( 61 EXPECT_EQ(
58 "Successful parse!\n", 62 "Successful parse!\n",
59 Munger.getTestResults()); 63 Munger.getTestResults());
60 64
61 // Show what happens when misdefining: @t1 = float" 65 // Show what happens when misdefining: @t1 = float"
62 const uint64_t AddSelfReference[] = { 66 const uint64_t AddSelfReference[] = {
63 ReplaceIndex, NaClBitcodeMunger::Replace, 3, 3, 1, Terminator 67 ReplaceIndex, NaClBitcodeMunger::Replace, 3, 3, 1, Terminator
64 }; 68 };
65 EXPECT_FALSE(Munger.runTest( 69 EXPECT_FALSE(Munger.runTest(
66 "@t1 = float(1)", 70 "@t1 = float(1)",
67 AddSelfReference, array_lengthof(AddSelfReference), 71 AddSelfReference, array_lengthof(AddSelfReference),
68 false)); 72 false));
69 EXPECT_EQ( 73 EXPECT_EQ(
70 "Error: Record doesn't have expected size or structure\n", 74 "Error: Record doesn't have expected size or structure\n",
71 Munger.getTestResults()); 75 Munger.getTestResults());
72 EXPECT_FALSE(Munger.runTest( 76 EXPECT_FALSE(Munger.runTest(
73 "@t1 = float(1)", 77 "@t1 = float(1)",
74 AddSelfReference, array_lengthof(AddSelfReference), 78 AddSelfReference, array_lengthof(AddSelfReference),
75 true)); 79 true));
76 EXPECT_EQ( 80 EXPECT_EQ(
77 "Error: (24:2) Invalid TYPE_CODE_FLOAT record\n" 81 "Error: (40:2) Invalid TYPE_CODE_FLOAT record\n"
78 "Error: Record doesn't have expected size or structure\n", 82 "Error: Record doesn't have expected size or structure\n",
79 Munger.getTestResults()); 83 Munger.getTestResults());
80 } 84 }
81 85
82 } // end of anonamous namespace. 86 } // end of anonamous namespace.
OLDNEW
« no previous file with comments | « unittests/Bitcode/NaClParseInstsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698