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

Unified Diff: unittests/Bitcode/NaClAbbrevErrorTests.cpp

Issue 1113023005: Add abilities to generate bitcode buffers from munged bitcode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Try to get better patch. Created 5 years, 7 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
Index: unittests/Bitcode/NaClAbbrevErrorTests.cpp
diff --git a/unittests/Bitcode/NaClAbbrevErrorTests.cpp b/unittests/Bitcode/NaClAbbrevErrorTests.cpp
index 38ceb42b2e79f8737d76f117183f51434a9ddb68..a858c07f0027ee9f6453f462bcde8da0e19bf48a 100644
--- a/unittests/Bitcode/NaClAbbrevErrorTests.cpp
+++ b/unittests/Bitcode/NaClAbbrevErrorTests.cpp
@@ -75,15 +75,27 @@ TEST(MyDeathNaClAbbrevErrorTests, BadAbbreviationIndex) {
ReplaceIndex, NaClMungedBitcode::Replace,
4, naclbitc::TYPE_CODE_VOID, Terminator,
};
+
+ // Show that by default, one can't write a bad abbreviation index.
DumpMunger.setRunAsDeathTest(true);
EXPECT_DEATH(
DumpMunger.runTest("Bad abbreviation index 4",
AbbrevIndex4, array_lengthof(AbbrevIndex4)),
+ ".*Error \\(Block 17\\)\\: Uses illegal abbreviation index\\:"
+ " 4\\: \\[2\\].*");
+
+ // Show that the corresponding error is generated when reading
+ // bitcode with a bad abbreviation index.
+ DumpMunger.WriteFlags.SaveBadAbbrevIndices = true;
+ EXPECT_DEATH(
+ DumpMunger.runTest("Bad abbreviation index 4",
+ AbbrevIndex4, array_lengthof(AbbrevIndex4)),
".*Fatal\\(35\\:0\\)\\: Invalid abbreviation \\# 4 defined for record.*");
// Test that bitcode reader reports problem correctly.
NaClParseBitcodeMunger Munger(BitcodeRecords,
array_lengthof(BitcodeRecords), Terminator);
+ 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
EXPECT_DEATH(
Munger.runTest("Bad abbreviation index",
AbbrevIndex4, array_lengthof(AbbrevIndex4), true),

Powered by Google App Engine
This is Rietveld 408576698