MLIR  20.0.0git
Tester.h
Go to the documentation of this file.
1 //===- Tester.h -------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the Tester class used in the MLIR Reduce tool.
10 //
11 // A Tester object is passed as an argument to the reduction passes and it is
12 // used to run the interestingness testing script on the different generated
13 // reduced variants of the test case.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef MLIR_REDUCER_TESTER_H
18 #define MLIR_REDUCER_TESTER_H
19 
20 #include <vector>
21 
22 #include "mlir/IR/BuiltinOps.h"
23 #include "llvm/ADT/SmallString.h"
24 #include "llvm/Support/Error.h"
25 #include "llvm/Support/FileSystem.h"
26 #include "llvm/Support/Program.h"
27 
28 namespace mlir {
29 
30 /// This class is used to keep track of the testing environment of the tool. It
31 /// contains a method to run the interestingness testing script on a MLIR test
32 /// case file.
33 class Tester {
34 public:
35  enum class Interestingness {
36  True,
37  False,
38  Untested,
39  };
40 
41  Tester(StringRef testScript, ArrayRef<std::string> testScriptArgs);
42 
43  /// Runs the interestingness testing script on a MLIR test case file. Returns
44  /// true if the interesting behavior is present in the test case or false
45  /// otherwise.
46  std::pair<Interestingness, size_t> isInteresting(ModuleOp module) const;
47 
48  /// Return whether the file in the given path is interesting.
49  Interestingness isInteresting(StringRef testCase) const;
50 
51 private:
52  StringRef testScript;
53  ArrayRef<std::string> testScriptArgs;
54 };
55 
56 } // namespace mlir
57 
58 #endif
This class is used to keep track of the testing environment of the tool.
Definition: Tester.h:33
Interestingness
Definition: Tester.h:35
Tester(StringRef testScript, ArrayRef< std::string > testScriptArgs)
Definition: Tester.cpp:23
std::pair< Interestingness, size_t > isInteresting(ModuleOp module) const
Runs the interestingness testing script on a MLIR test case file.
Definition: Tester.cpp:27
Include the generated interface declarations.