Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- llvm/unittest/Bitcode/NaClAbbrevErrorTests.cpp ---------------------===// | 1 //===- llvm/unittest/Bitcode/NaClAbbrevErrorTests.cpp ---------------------===// |
| 2 // Tests parser for PNaCl bitcode instructions. | 2 // Tests parser for PNaCl bitcode instructions. |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 " 64:0|0: <65534> |}\n" | 68 " 64:0|0: <65534> |}\n" |
| 69 "", | 69 "", |
| 70 DumpMunger.getTestResults()); | 70 DumpMunger.getTestResults()); |
| 71 | 71 |
| 72 // Shows what happens when we change the abbreviation index to an | 72 // Shows what happens when we change the abbreviation index to an |
| 73 // illegal value. | 73 // illegal value. |
| 74 const uint64_t AbbrevIndex4[] = { | 74 const uint64_t AbbrevIndex4[] = { |
| 75 ReplaceIndex, NaClMungedBitcode::Replace, | 75 ReplaceIndex, NaClMungedBitcode::Replace, |
| 76 4, naclbitc::TYPE_CODE_VOID, Terminator, | 76 4, naclbitc::TYPE_CODE_VOID, Terminator, |
| 77 }; | 77 }; |
| 78 | |
| 79 // Show that by default, one can't write a bad abbreviation index. | |
| 78 DumpMunger.setRunAsDeathTest(true); | 80 DumpMunger.setRunAsDeathTest(true); |
| 79 EXPECT_DEATH( | 81 EXPECT_DEATH( |
| 80 DumpMunger.runTest("Bad abbreviation index 4", | 82 DumpMunger.runTest("Bad abbreviation index 4", |
| 81 AbbrevIndex4, array_lengthof(AbbrevIndex4)), | 83 AbbrevIndex4, array_lengthof(AbbrevIndex4)), |
| 84 ".*Error \\(Block 17\\)\\: Uses illegal abbreviation index\\:" | |
| 85 " 4\\: \\[2\\].*"); | |
| 86 | |
| 87 // Show that the corresponding error is generated when reading | |
| 88 // bitcode with a bad abbreviation index. | |
| 89 DumpMunger.WriteFlags.SaveBadAbbrevIndices = true; | |
| 90 EXPECT_DEATH( | |
| 91 DumpMunger.runTest("Bad abbreviation index 4", | |
| 92 AbbrevIndex4, array_lengthof(AbbrevIndex4)), | |
| 82 ".*Fatal\\(35\\:0\\)\\: Invalid abbreviation \\# 4 defined for record.*"); | 93 ".*Fatal\\(35\\:0\\)\\: Invalid abbreviation \\# 4 defined for record.*"); |
| 83 | 94 |
| 84 // Test that bitcode reader reports problem correctly. | 95 // Test that bitcode reader reports problem correctly. |
| 85 NaClParseBitcodeMunger Munger(BitcodeRecords, | 96 NaClParseBitcodeMunger Munger(BitcodeRecords, |
| 86 array_lengthof(BitcodeRecords), Terminator); | 97 array_lengthof(BitcodeRecords), Terminator); |
| 98 Munger.WriteFlags.SaveBadAbbrevIndices = true; | |
|
jvoung (off chromium)
2015/05/06 22:08:09
It looks like there you could also separately test
Karl
2015/05/07 20:09:18
Added recovery cases. Also refactored the RunAsDea
| |
| 87 EXPECT_DEATH( | 99 EXPECT_DEATH( |
| 88 Munger.runTest("Bad abbreviation index", | 100 Munger.runTest("Bad abbreviation index", |
| 89 AbbrevIndex4, array_lengthof(AbbrevIndex4), true), | 101 AbbrevIndex4, array_lengthof(AbbrevIndex4), true), |
| 90 ".*Fatal\\(35\\:0\\)\\: Invalid abbreviation \\# 4 defined for record.*"); | 102 ".*Fatal\\(35\\:0\\)\\: Invalid abbreviation \\# 4 defined for record.*"); |
| 91 } | 103 } |
| 92 | 104 |
| 93 } // end of anonymous namespace. | 105 } // end of anonymous namespace. |
| OLD | NEW |