P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::TestSpec Class Reference

Public Member Functions

 TestSpec (Packet ingressPacket, std::optional< Packet > egressPacket, std::vector< std::reference_wrapper< const TraceEvent > > traces)
 
void addTestObject (cstring category, cstring objectLabel, const TestObject *object)
 
std::optional< const Packet * > getEgressPacket () const
 
const PacketgetIngressPacket () const
 
const std::map< cstring, const TableConfig > * getTables () const
 
const TestObjectgetTestObject (cstring category, cstring objectLabel, bool checked) const
 
template<class T >
auto * getTestObject (cstring category, cstring objectLabel, bool checked) const
 
TestObjectMap getTestObjectCategory (cstring category) const
 
const std::vector< std::reference_wrapper< const TraceEvent > > * getTraces () const
 

Static Public Attributes

static constexpr int HIGH_PRIORITY = 100
 
static constexpr int LOW_PRIORITY = 1
 
static constexpr int NO_PRIORITY = -1
 Priority definitions for LPM and ternary entries.
 
static constexpr int TTL = 0
 

Member Function Documentation

◆ addTestObject()

void P4::P4Tools::P4Testgen::TestSpec::addTestObject ( cstring category,
cstring objectLabel,
const TestObject * object )

Add a test object to the test specification with

Parameters
categoryas the object category (for example, "tables", "registers", "action_profiles") and objectLabel as the concrete, individual label of the object.

◆ getEgressPacket()

std::optional< const Packet * > P4::P4Tools::P4Testgen::TestSpec::getEgressPacket ( ) const
nodiscard
Returns
the expected output packet for this test.

◆ getIngressPacket()

const Packet * P4::P4Tools::P4Testgen::TestSpec::getIngressPacket ( ) const
nodiscard
Returns
the input packet for this test.

◆ getTables()

const std::map< cstring, const TableConfig > * P4::P4Tools::P4Testgen::TestSpec::getTables ( ) const
nodiscard
Returns
the list of tables that need to be configured for this test.

◆ getTestObject() [1/2]

const TestObject * P4::P4Tools::P4Testgen::TestSpec::getTestObject ( cstring category,
cstring objectLabel,
bool checked ) const
nodiscard
Returns
a test object for the given category and objectlabel. Returns a BUG if checked is true and the object is not found.

◆ getTestObject() [2/2]

template<class T >
auto * P4::P4Tools::P4Testgen::TestSpec::getTestObject ( cstring category,
cstring objectLabel,
bool checked ) const
inlinenodiscard
Returns
the test object using the provided category and object label. If
Parameters
checkedis enabled, a BUG is thrown if the object label does not exist. Also casts the test object to the specified type. If the type does not match, a BUG is thrown.

◆ getTestObjectCategory()

TestObjectMap P4::P4Tools::P4Testgen::TestSpec::getTestObjectCategory ( cstring category) const
nodiscard
Returns
the map of test objects for a given category.

◆ getTraces()

const std::vector< std::reference_wrapper< const TraceEvent > > * P4::P4Tools::P4Testgen::TestSpec::getTraces ( ) const
nodiscard
Returns
the list of traces that has been executed