P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::TestBackEnd Class Referenceabstract
Inheritance diagram for P4::P4Tools::P4Testgen::TestBackEnd:
[legend]

Classes

struct  TestInfo
 

Public Member Functions

 TestBackEnd (const TestBackEnd &)=default
 
 TestBackEnd (TestBackEnd &&)=default
 
std::optional< std::reference_wrapper< const FinalState > > computeConcolicVariables (const FinalState &state) const
 
virtual const TestSpeccreateTestSpec (const ExecutionState *executionState, const Model *finalModel, const TestInfo &testInfo)=0
 
float getCoverage () const
 Returns coverage achieved by all the processed tests.
 
const ProgramInfogetProgramInfo () const
 Returns the program info.
 
const TestBackendConfigurationgetTestBackendConfiguration () const
 Returns the configuration options for the test back end.
 
int64_t getTestCount () const
 Returns test count.
 
const AbstractTestList & getTests () const
 
TestBackEndoperator= (const TestBackEnd &)=delete
 
TestBackEndoperator= (TestBackEnd &&)=delete
 
virtual bool printTestInfo (const ExecutionState *executionState, const TestInfo &testInfo, const IR::Expression *outputPortExpr)
 
virtual TestInfo produceTestInfo (const ExecutionState *executionState, const Model *finalModel, const IR::Expression *outputPacketExpr, const IR::Expression *outputPortExpr, const std::vector< std::reference_wrapper< const TraceEvent > > *programTraces)
 
virtual bool run (const FinalState &state)
 The callback that is executed by the symbolic executor.
 

Protected Member Functions

 TestBackEnd (const ProgramInfo &programInfo, const TestBackendConfiguration &testBackendConfiguration, SymbolicExecutor &symbex)
 
bool needsToTerminate (int64_t testCount) const
 

Protected Attributes

float coverage = 0
 The accumulated coverage of all finished test cases. Number in range [0, 1].
 
int64_t maxTests
 Test maximum number of tests that are to be produced.
 
SymbolicExecutorsymbex
 
AbstractTestList tests
 The list of tests accumulated in the test back end.
 
TestFrameworktestWriter = nullptr
 Writes the tests out to a file.
 

Class Documentation

◆ P4::P4Tools::P4Testgen::TestBackEnd::TestInfo

struct P4::P4Tools::P4Testgen::TestBackEnd::TestInfo
Class Members
const Constant * inputPacket

The concrete value of the input packet. This is a slice of the program packet according to packetSizeInInt.

int inputPort The input port of the packet.
const Constant * outputPacket The concrete value of the output packet as modified by the packet.
int outputPort The output port of the packet.
bool packetIsDropped = false Indicates whether the packet is dropped.
const Constant * packetTaintMask The taint mask.
const vector< reference_wrapper< const TraceEvent > > programTraces The traces that have been collected during execution of this particular test path.

Member Function Documentation

◆ computeConcolicVariables()

std::optional< std::reference_wrapper< const FinalState > > P4::P4Tools::P4Testgen::TestBackEnd::computeConcolicVariables ( const FinalState & state) const
nodiscard
Returns
a new modules with all concolic variables in the program resolved.

◆ createTestSpec()

virtual const TestSpec * P4::P4Tools::P4Testgen::TestBackEnd::createTestSpec ( const ExecutionState * executionState,
const Model * finalModel,
const TestInfo & testInfo )
pure virtual
Returns
the test specification which is consumed by the test back ends.

Implemented in P4::P4Tools::P4Testgen::Bmv2::Bmv2TestBackend, P4::P4Tools::P4Testgen::EBPF::EBPFTestBackend, and P4::P4Tools::P4Testgen::Pna::PnaTestBackend.

◆ getTests()

const AbstractTestList & P4::P4Tools::P4Testgen::TestBackEnd::getTests ( ) const
inlinenodiscard

Returns the list of tests accumulated in the test back end. If the test write is in file mode this list will be empty.

◆ printTestInfo()

bool P4::P4Tools::P4Testgen::TestBackEnd::printTestInfo ( const ExecutionState * executionState,
const TestInfo & testInfo,
const IR::Expression * outputPortExpr )
virtual

Prints information about this particular test path.

Returns
false if the test generation is to be aborted (for example when the port is tainted.)

◆ produceTestInfo()

TestBackEnd::TestInfo P4::P4Tools::P4Testgen::TestBackEnd::produceTestInfo ( const ExecutionState * executionState,
const Model * finalModel,
const IR::Expression * outputPacketExpr,
const IR::Expression * outputPortExpr,
const std::vector< std::reference_wrapper< const TraceEvent > > * programTraces )
virtual
Returns
a TestInfo objects, which contains information about the input/output ports, the taint mask, the packet sizes, etc...

Reimplemented in P4::P4Tools::P4Testgen::Bmv2::Bmv2TestBackend, P4::P4Tools::P4Testgen::EBPF::EBPFTestBackend, and P4::P4Tools::P4Testgen::Pna::PnaTestBackend.

Member Data Documentation

◆ symbex

SymbolicExecutor& P4::P4Tools::P4Testgen::TestBackEnd::symbex
protected

Pointer to the symbolic executor. TODO: Remove this. We only need to update coverage tracking.