Chromium Code Reviews| Index: unittest/BitcodeMunge.h |
| diff --git a/unittest/BitcodeMunge.h b/unittest/BitcodeMunge.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d82d1495e5348aedd553159efc7acc605dc1ed24 |
| --- /dev/null |
| +++ b/unittest/BitcodeMunge.h |
| @@ -0,0 +1,47 @@ |
| +//===- BitcodeMunge.h - 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. Uses NaCl's |
| +// bitcode munger to do this. |
| +// |
| +//===----------------------------------------------------------------------===// |
| + |
| +#ifndef SUBZERO_SRC_BITCODEMUNGE_H |
|
Jim Stichnoth
2015/01/08 23:45:25
Change this define to reflect the new file locatio
Karl
2015/01/09 16:12:32
Done.
|
| +#define SUBZERO_SRC_BITCODEMUNGE_H |
| + |
| +#include "llvm/Bitcode/NaCl/NaClBitcodeMunge.h" |
| + |
| +namespace IceTest { |
| + |
| +// Class to run tests on subzero's bitcode parser. Runs a Subzero |
|
Jim Stichnoth
2015/01/08 23:45:25
Capitalize Subzero
Karl
2015/01/09 16:12:32
Done.
|
| +// translation, using (possibly) edited bicode record values. For |
|
Jim Stichnoth
2015/01/08 23:45:25
bitcode
Karl
2015/01/09 16:12:32
Done.
|
| +// more details on how to represent the input arrays, see |
| +// NaClBitcodeMunge.h. |
| +class SubzeroBitcodeMunger : public llvm::NaClBitcodeMunger { |
| +public: |
| + SubzeroBitcodeMunger(const uint64_t Records[], size_t RecordSize, |
| + uint64_t RecordTerminator) |
| + : llvm::NaClBitcodeMunger(Records, RecordSize, RecordTerminator) {} |
| + |
| + /// Runs PNaClTranslator to translate bitcode records (with defined |
| + /// record Munges), and puts output into DumpResults. Returns true |
| + /// if parse is successful. |
| + bool runTest(const char* TestName, const uint64_t Munges[], |
| + size_t MungeSize); |
| + |
| + /// Same as above, but without any edits. |
| + bool runTest(const char* TestName) { |
| + uint64_t NoMunges[] = {0}; |
| + return runTest(TestName, NoMunges, 0); |
| + } |
| +}; |
| + |
| +} // end of namespace IceTest |
| + |
| +#endif // SUBZERO_SRC_BITCODEMUNGE_H |