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

Bmv2TestFramework provides common utility functions for BMv2-style test frameworks. More...

#include <common.h>

Inheritance diagram for P4::P4Tools::P4Testgen::Bmv2::Bmv2TestFramework:
[legend]

Public Member Functions

 Bmv2TestFramework (const TestBackendConfiguration &testBackendConfiguration)
 
- Public Member Functions inherited from P4::P4Tools::P4Testgen::TestFramework
bool isInFileMode () const
 @Returns true if the test framework is configured to write to a file.
 
virtual AbstractTestReferenceOrError produceTest (const TestSpec *spec, cstring selectedBranches, size_t testIdx, float currentCoverage)
 
virtual void writeTestToFile (const TestSpec *spec, cstring selectedBranches, size_t testIdx, float currentCoverage)=0
 

Protected Member Functions

virtual inja::json getClone (const TestObjectMap &cloneSpecs) const
 Returns the configuration for a cloned packet configuration.
 
virtual inja::json getControlPlane (const TestSpec *testSpec) const
 Converts all the control plane objects into Inja format.
 
virtual inja::json getControlPlaneForTable (const TableMatchMap &matches, const std::vector< ActionArg > &args) const
 Helper function for the control plane table inja objects.
 
virtual inja::json getControlPlaneTable (const TableConfig &tblConfig) const
 Converts a table configuration into Inja format.
 
virtual inja::json getExpectedPacket (const TestSpec *testSpec) const
 Converts the output packet, port, and mask into Inja format.
 
virtual inja::json::array_t getMeter (const TestObjectMap &meterValues) const
 
virtual inja::json getSend (const TestSpec *testSpec) const
 Converts the input packet and port into Inja format.
 
- Protected Member Functions inherited from P4::P4Tools::P4Testgen::TestFramework
 TestFramework (const TestBackendConfiguration &testBackendConfiguration)
 Creates a generic test framework.
 
const TestBackendConfigurationgetTestBackendConfiguration () const
 Returns the configuration options for the test back end.
 

Static Protected Member Functions

static std::string formatHexExpressionWithSeparators (const IR::Expression &expr)
 Wrapper helper function that automatically inserts separators for hex strings.
 
- Static Protected Member Functions inherited from P4::P4Tools::P4Testgen::TestFramework
static void checkForDefaultActionOverride (inja::json &tblJson, const TableConfig *tblConfig)
 
template<class ProfileType , class SelectorType >
static void checkForTableActionProfile (inja::json &tblJson, std::map< cstring, cstring > &apAsMap, const TableConfig *tblConfig)
 
template<class ProfileType >
static void collectActionProfileDeclarations (const TestSpec *testSpec, inja::json &controlPlaneJson, const std::map< cstring, cstring > &apAsMap)
 Collect all the action profile objects. These will have to be declared in the test.
 
static inja::json getTrace (const TestSpec *testSpec)
 Converts the traces of this test into a string representation and Inja object.
 

Detailed Description

Bmv2TestFramework provides common utility functions for BMv2-style test frameworks.

Member Function Documentation

◆ getMeter()

inja::json::array_t P4::P4Tools::P4Testgen::Bmv2::Bmv2TestFramework::getMeter ( const TestObjectMap & meterValues) const
nodiscardprotectedvirtual
Returns
the configuration for a meter call (may set the meter to GREEN, YELLOW, or RED)