Index: include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h |
diff --git a/include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h b/include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h |
index d9a46ab91a2c0a36225fa89fa97b9bd74a8fc0ec..15208ae50961646b6fd431cb7c77d00f29d8613c 100644 |
--- a/include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h |
+++ b/include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h |
@@ -73,13 +73,13 @@ public: |
} |
/// Creates MungedInput and DumpStream for running tests, based on |
- /// given Munges. |
- void setupTest( |
+ /// given Munges. Returns true if able to set up test. |
+ bool setupTest( |
const char *TestName, const uint64_t Munges[], size_t MungesSize, |
bool AddHeader); |
- /// Cleans up state after a test. |
- void cleanupTest(); |
+ /// Cleans up state after a test. Returns true if no errors found. |
+ bool cleanupTest(); |
/// Returns the resulting string generated by the corresponding test. |
const std::string &getTestResults() const { |
@@ -110,6 +110,16 @@ public: |
WriteFlags.setWriteBadAbbrevIndex(NewValue); |
} |
+ /// Get access to munged bitcodes. |
+ NaClMungedBitcode &getMungedBitcode() { |
+ return MungedBitcode; |
+ } |
+ |
+ /// Apply given munges to the munged bitcode. |
+ void munge(const uint64_t Munges[], size_t MungesSize) { |
+ MungedBitcode.munge(Munges, MungesSize, RecordTerminator); |
+ } |
+ |
protected: |
// The bitcode records being munged. |
NaClMungedBitcode MungedBitcode; |
@@ -151,6 +161,25 @@ protected: |
} |
}; |
+/// Class to run tests writing munged bitcode. |
+class NaClWriteMunger : public NaClBitcodeMunger { |
+public: |
+ NaClWriteMunger(const uint64_t Records[], size_t RecordsSize, |
+ uint64_t RecordTerminator) |
+ : NaClBitcodeMunger(Records, RecordsSize, RecordTerminator) {} |
+ |
+ /// Writes munged bitcode and puts error messages into DumpResults. |
+ /// Returns true if successful. |
+ bool runTest(const char* TestName, const uint64_t Munges[], |
+ size_t MungesSize); |
+ |
+ // Same as above, but without any edits. |
+ bool runTest(const char* TestName) { |
+ uint64_t NoMunges[] = {0}; |
+ return runTest(TestName, NoMunges, 0); |
+ } |
+}; |
+ |
/// Class to run tests for function llvm::NaClObjDump. |
class NaClObjDumpMunger : public NaClBitcodeMunger { |
public: |