Add ability to test parsing of bitcode records in Subzero.

Extends the NaCl bitcode munger so that the PNaClTranslator parser
can be applied to the defined sequence of record values.

BUG=None
R=jvoung@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/800883006
diff --git a/unittest/BitcodeMunge.cpp b/unittest/BitcodeMunge.cpp
new file mode 100644
index 0000000..a6d2838
--- /dev/null
+++ b/unittest/BitcodeMunge.cpp
@@ -0,0 +1,40 @@
+//===- BitcodeMunge.cpp - Subzero Bitcode Munger ----------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Test harness for testing malformed bitcode files in Subzero.
+//
+//===----------------------------------------------------------------------===//
+
+#include "BitcodeMunge.h"
+#include "IceCfg.h"
+#include "IceClFlags.h"
+#include "PNaClTranslator.h"
+#include "IceTypes.h"
+
+namespace IceTest {
+
+bool IceTest::SubzeroBitcodeMunger::runTest(
+    const char* TestName, const uint64_t Munges[], size_t MungeSize) {
+  const bool AddHeader = true;
+  setupTest(TestName, Munges, MungeSize, AddHeader);
+
+  Ice::ClFlags Flags;
+  Flags.AllowErrorRecovery = true;
+  Flags.GenerateUnitTestMessages = true;
+  Ice::GlobalContext Ctx(DumpStream, DumpStream, nullptr,
+                         Ice::IceV_Instructions, Ice::Target_X8632,
+                         Ice::Opt_m1, "", Flags);
+  Ice::PNaClTranslator Translator(&Ctx, Flags);
+  Translator.translateBuffer(TestName, MungedInput.get());
+
+  cleanupTest();
+  return Translator.getErrorStatus() == 0;
+}
+
+} // end of namespace IceTest