CIRCT  19.0.0git
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
circt::TestCase Class Reference

A single test case to be run by a tester. More...

#include <Tester.h>

Collaboration diagram for circt::TestCase:
Collaboration graph
[legend]

Public Member Functions

 TestCase (const Tester &tester, mlir::ModuleOp module)
 Create a test case with an MLIR module that will be written to a temporary file on disk. More...
 
 TestCase (const Tester &tester, llvm::Twine filepath)
 Create a test case for an already-prepared file on disk. More...
 
bool isValid ()
 Check whether the MLIR module is valid. More...
 
llvm::StringRef getFilepath ()
 Determine the path to the MLIR module on disk. More...
 
size_t getSize ()
 Determine the size of the MLIR module on disk. More...
 
bool isInteresting ()
 Run the tester on the MLIR module and return whether it is deemed interesting. More...
 

Private Member Functions

void ensureFileOnDisk ()
 Ensure filepath and size are populated, and that the test case is in a file on disk. More...
 

Private Attributes

const Testertester
 The tester that is used to run this test case. More...
 
mlir::ModuleOp module
 The module to be tested. More...
 
llvm::SmallString< 32 > filepath
 The path on disk where the test case is located. More...
 
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 writing. More...
 
std::optional< bool > valid
 Whether the MLIR module validation has run, and its result. More...
 
std::optional< size_t > size
 Whether the size of the test case on disk has already been determined, and if yes, that size. More...
 
std::optional< bool > interesting
 Whether the tester has run on this test case, and its result. More...
 

Friends

class Tester
 

Detailed Description

A single test case to be run by a tester.

This is a helper object that wraps a ModuleOp and can be used to query initial information about the test, such as validity of the module and size on disk, before the test is actually executed.

Definition at line 74 of file Tester.h.

Constructor & Destructor Documentation

◆ TestCase() [1/2]

circt::TestCase::TestCase ( const Tester tester,
mlir::ModuleOp  module 
)
inline

Create a test case with an MLIR module that will be written to a temporary file on disk.

The TestCase will clean up the temporary file after use.

Definition at line 78 of file Tester.h.

◆ TestCase() [2/2]

circt::TestCase::TestCase ( const Tester tester,
llvm::Twine  filepath 
)
inline

Create a test case for an already-prepared file on disk.

The caller remains responsible for cleaning up the file on disk.

Definition at line 83 of file Tester.h.

References filepath.

Member Function Documentation

◆ ensureFileOnDisk()

void TestCase::ensureFileOnDisk ( )
private

Ensure filepath and size are populated, and that the test case is in a file on disk.

Definition at line 118 of file Tester.cpp.

References assert(), file, filepath, module, and size.

Referenced by getFilepath(), getSize(), and isInteresting().

◆ getFilepath()

StringRef TestCase::getFilepath ( )

Determine the path to the MLIR module on disk.

Actual writing to disk is only performed on the first call; subsequent calls return the cached result.

Definition at line 88 of file Tester.cpp.

References ensureFileOnDisk(), filepath, and isValid().

◆ getSize()

size_t TestCase::getSize ( )

Determine the size of the MLIR module on disk.

Actual writing to disk is only performed on the first call; subsequent calls return the cached result.

Definition at line 97 of file Tester.cpp.

References ensureFileOnDisk(), isValid(), and size.

◆ isInteresting()

bool TestCase::isInteresting ( )

Run the tester on the MLIR module and return whether it is deemed interesting.

Actual testing is only performed on the first call; subsequent calls return the cached result.

Definition at line 107 of file Tester.cpp.

References ensureFileOnDisk(), filepath, interesting, circt::Tester::isInteresting(), isValid(), and tester.

◆ isValid()

bool TestCase::isValid ( )

Check whether the MLIR module is valid.

Actual validation is only performed on the first call; subsequent calls return the cached result.

Definition at line 77 of file Tester.cpp.

References module, and valid.

Referenced by getFilepath(), getSize(), and isInteresting().

Friends And Related Function Documentation

◆ Tester

friend class Tester
friend

Definition at line 107 of file Tester.h.

Member Data Documentation

◆ file

std::unique_ptr<llvm::ToolOutputFile> circt::TestCase::file
private

In case this test case has created a temporary file on disk, this is the ToolOutputFile that did the writing.

Keeping this class around ensures that the file will be cleaned up properly afterwards. This field remains null if the user already has provided a filepath in the constructor.

Definition at line 124 of file Tester.h.

Referenced by ensureFileOnDisk().

◆ filepath

llvm::SmallString<32> circt::TestCase::filepath
private

The path on disk where the test case is located.

Definition at line 118 of file Tester.h.

Referenced by ensureFileOnDisk(), getFilepath(), isInteresting(), and TestCase().

◆ interesting

std::optional<bool> circt::TestCase::interesting
private

Whether the tester has run on this test case, and its result.

Definition at line 132 of file Tester.h.

Referenced by isInteresting().

◆ module

mlir::ModuleOp circt::TestCase::module
private

◆ size

std::optional<size_t> circt::TestCase::size
private

Whether the size of the test case on disk has already been determined, and if yes, that size.

Definition at line 130 of file Tester.h.

Referenced by esi.types.ArrayType::bit_width(), esi.types.ArrayType::deserialize(), ensureFileOnDisk(), getSize(), and esi.types.ArrayType::is_valid().

◆ tester

const Tester& circt::TestCase::tester
private

The tester that is used to run this test case.

Definition at line 114 of file Tester.h.

Referenced by isInteresting().

◆ valid

std::optional<bool> circt::TestCase::valid
private

Whether the MLIR module validation has run, and its result.

Definition at line 127 of file Tester.h.

Referenced by isValid().


The documentation for this class was generated from the following files: