14 #include "mlir/IR/Verifier.h"
15 #include "llvm/Support/ToolOutputFile.h"
19 using namespace circt;
25 Tester::Tester(StringRef testScript, ArrayRef<std::string> testScriptArgs,
27 : testScript(testScript), testScriptArgs(testScriptArgs),
28 testMustFail(testMustFail) {}
31 auto test =
get(module);
32 return std::make_pair(test.isInteresting(), test.getSize());
41 SmallVector<StringRef> testerArgs;
44 testerArgs.push_back(testCase);
48 int result = llvm::sys::ExecuteAndWait(
49 testScript, testerArgs, std::nullopt, std::nullopt,
52 llvm::report_fatal_error(
53 Twine(
"Error running interestingness test: ") + errMsg,
false);
126 std::error_code ec = llvm::sys::fs::createTemporaryFile(
127 "circt-reduce",
"mlir", fd,
filepath);
129 llvm::report_fatal_error(
130 Twine(
"Error making unique filename: ") + ec.message(),
false);
133 file = std::make_unique<llvm::ToolOutputFile>(
filepath, fd);
136 if (
file->os().has_error())
137 llvm::report_fatal_error(llvm::Twine(
"Error emitting the IR to file `") +
149 std::error_code ec = llvm::sys::fs::file_size(
filepath, fileSize);
151 llvm::report_fatal_error(Twine(
"Error determining size of file `") +
assert(baseType &&"element must be base type")
A single test case to be run by a tester.
std::optional< bool > interesting
Whether the tester has run on this test case, and its result.
llvm::SmallString< 32 > filepath
The path on disk where the test case is located.
mlir::ModuleOp module
The module to be tested.
size_t getSize()
Determine the size of the MLIR module on disk.
bool isValid()
Check whether the MLIR module is valid.
std::optional< size_t > size
Whether the size of the test case on disk has already been determined, and if yes,...
void ensureFileOnDisk()
Ensure filepath and size are populated, and that the test case is in a file on disk.
std::optional< bool > valid
Whether the MLIR module validation has run, and its result.
bool isInteresting()
Run the tester on the MLIR module and return whether it is deemed interesting.
const Tester & tester
The tester that is used to run this test case.
llvm::StringRef getFilepath()
Determine the path to the MLIR module on disk.
std::unique_ptr< llvm::ToolOutputFile > file
In case this test case has created a temporary file on disk, this is the ToolOutputFile that did the ...
llvm::StringRef testScript
The binary to execute in order to check a reduction attempt for interestingness.
bool testMustFail
Consider the testcase to be interesting if it fails rather than on exit code 0.
TestCase get(mlir::ModuleOp module) const
Create a new test case for the given module.
std::pair< bool, size_t > isInteresting(mlir::ModuleOp module) const
Runs the interestingness testing script on a MLIR test case file.
llvm::ArrayRef< std::string > testScriptArgs
Additional arguments to pass to testScript.
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.