| OLD | NEW |
| 1 //===- NaClBitcodeMunge.h - Bitcode Munger ----------------------*- C++ -*-===// | 1 //===- NaClBitcodeMunge.h - Bitcode Munger ----------------------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // Test harness for generating a PNaCl bitcode memory buffer from | 10 // Test harness for generating a PNaCl bitcode memory buffer from |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 SmallVector<char, 1024> MungedInputBuffer; | 143 SmallVector<char, 1024> MungedInputBuffer; |
| 144 /// The write flags to use when writing bitcode. | 144 /// The write flags to use when writing bitcode. |
| 145 NaClMungedBitcode::WriteFlags WriteFlags; | 145 NaClMungedBitcode::WriteFlags WriteFlags; |
| 146 // Flag to redirect dump stream if running death test. | 146 // Flag to redirect dump stream if running death test. |
| 147 bool RunAsDeathTest; | 147 bool RunAsDeathTest; |
| 148 | 148 |
| 149 // Records that an error occurred, and returns stream to print error | 149 // Records that an error occurred, and returns stream to print error |
| 150 // message to. | 150 // message to. |
| 151 raw_ostream &Error() { | 151 raw_ostream &Error() { |
| 152 FoundErrors = true; | 152 FoundErrors = true; |
| 153 return getDumpStream() << "Error: "; | 153 return getDumpStream() << "error: "; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Returns the lines containing the given Substring, from the string | 156 // Returns the lines containing the given Substring, from the string |
| 157 // getTestResults(). If MustBePrefix, then Substring must match at | 157 // getTestResults(). If MustBePrefix, then Substring must match at |
| 158 // the beginning of the line. | 158 // the beginning of the line. |
| 159 std::string getLinesWithTextMatch(const std::string &Substring, | 159 std::string getLinesWithTextMatch(const std::string &Substring, |
| 160 bool MustBePrefix = false) const; | 160 bool MustBePrefix = false) const; |
| 161 | 161 |
| 162 // Returns the log stream to use. When running death tests, redirect output | 162 // Returns the log stream to use. When running death tests, redirect output |
| 163 // to the error stream (rather than buffering in DumpStream), so that | 163 // to the error stream (rather than buffering in DumpStream), so that |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 // Class to run tests for function NaClParseBitcodeFile. | 268 // Class to run tests for function NaClParseBitcodeFile. |
| 269 class NaClParseBitcodeMunger : public NaClBitcodeMunger { | 269 class NaClParseBitcodeMunger : public NaClBitcodeMunger { |
| 270 public: | 270 public: |
| 271 NaClParseBitcodeMunger(const uint64_t Records[], size_t RecordsSize, | 271 NaClParseBitcodeMunger(const uint64_t Records[], size_t RecordsSize, |
| 272 uint64_t RecordTerminator) | 272 uint64_t RecordTerminator) |
| 273 : NaClBitcodeMunger(Records, RecordsSize, RecordTerminator) {} | 273 : NaClBitcodeMunger(Records, RecordsSize, RecordTerminator) {} |
| 274 | 274 |
| 275 /// Runs function llvm::NaClParseBitcodeFile, and puts error messages | 275 /// Runs function llvm::NaClParseBitcodeFile, and puts error messages |
| 276 /// into DumpResults. Returns true if parse is successful. | 276 /// into DumpResults. Returns true if parse is successful. |
| 277 bool runTest(const uint64_t Munges[], size_t MungesSize, bool VerboseErrors); | 277 /// TODO(kschimpf) Remove VerboseErrors, no longer useful. |
| 278 bool runTest(const uint64_t Munges[], size_t MungesSize, |
| 279 bool VerboseErrors = false); |
| 278 | 280 |
| 279 // Same as above, but without any edits. | 281 // Same as above, but without any edits. |
| 280 bool runTest(bool VerboseErrors) { | 282 /// TODO(kschimpf) Remove VerboseErrors, no longer useful. |
| 283 bool runTest(bool VerboseErrors = false) { |
| 281 uint64_t NoMunges[] = {0}; | 284 uint64_t NoMunges[] = {0}; |
| 282 return runTest(NoMunges, 0, VerboseErrors); | 285 return runTest(NoMunges, 0, VerboseErrors); |
| 283 } | 286 } |
| 284 }; | 287 }; |
| 285 | 288 |
| 286 // Class to run tests for NaClBitcodeCompressor.compress(). | 289 // Class to run tests for NaClBitcodeCompressor.compress(). |
| 287 class NaClCompressMunger : public NaClBitcodeMunger { | 290 class NaClCompressMunger : public NaClBitcodeMunger { |
| 288 public: | 291 public: |
| 289 NaClCompressMunger(const uint64_t Records[], size_t RecordsSize, | 292 NaClCompressMunger(const uint64_t Records[], size_t RecordsSize, |
| 290 uint64_t RecordTerminator) | 293 uint64_t RecordTerminator) |
| 291 : NaClBitcodeMunger(Records, RecordsSize, RecordTerminator) {} | 294 : NaClBitcodeMunger(Records, RecordsSize, RecordTerminator) {} |
| 292 | 295 |
| 293 bool runTest(const uint64_t Munges[], size_t MungesSize); | 296 bool runTest(const uint64_t Munges[], size_t MungesSize); |
| 294 | 297 |
| 295 bool runTest() { | 298 bool runTest() { |
| 296 uint64_t NoMunges[] = {0}; | 299 uint64_t NoMunges[] = {0}; |
| 297 return runTest(NoMunges, 0); | 300 return runTest(NoMunges, 0); |
| 298 } | 301 } |
| 299 }; | 302 }; |
| 300 | 303 |
| 301 } // end namespace llvm. | 304 } // end namespace llvm. |
| 302 | 305 |
| 303 #endif // LLVM_BITCODE_NACL_NACLBITCODEMUNGE_H | 306 #endif // LLVM_BITCODE_NACL_NACLBITCODEMUNGE_H |
| OLD | NEW |