P4C
The P4 Compiler
|
#include <test_framework.h>
Public Member Functions | |
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 | |
TestFramework (const TestBackendConfiguration &testBackendConfiguration) | |
Creates a generic test framework. | |
const TestBackendConfiguration & | getTestBackendConfiguration () const |
Returns the configuration options for the test back end. | |
Static Protected Member Functions | |
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. | |
THe default base class for the various test frameworks. Every test framework has a test name and a seed associated with it. Also contains a variety of common utility functions.
|
inlinestaticprotected |
Check whether the table object has an overridden default action. In this case, we assume there are no keys and we just set the default action of the table.
|
inlinestaticprotected |
Checks whether a table object has an action profile or selector associated with it. If that is the case, we set a boolean flag for this particular inja object.
|
virtual |
The method used to return the test case. This method is optional to each test framework.
spec | the testcase specification to be outputted. |
selectedBranches | string describing branches selected for this testcase. |
testIdx | testcase unique number identifier. TODO: Make this a member? |
currentCoverage | current coverage ratio (between 0.0 and 1.0). |
Reimplemented in P4::P4Tools::P4Testgen::Bmv2::Protobuf, and P4::P4Tools::P4Testgen::Bmv2::ProtobufIr.
|
pure virtual |
The method used to output the test case to be implemented by all the test frameworks (eg. STF, PTF, etc.).
spec | the testcase specification to be outputted. |
selectedBranches | string describing branches selected for this testcase. |
testIdx | testcase unique number identifier. TODO: Make this a member? |
currentCoverage | current coverage ratio (between 0.0 and 1.0) TODO (https://github.com/p4lang/p4c/issues/4403): This should not return void but instead a status. |
Implemented in P4::P4Tools::P4Testgen::Bmv2::Metadata, P4::P4Tools::P4Testgen::Bmv2::Protobuf, P4::P4Tools::P4Testgen::Bmv2::ProtobufIr, P4::P4Tools::P4Testgen::Bmv2::PTF, P4::P4Tools::P4Testgen::Bmv2::STF, P4::P4Tools::P4Testgen::EBPF::STF, P4::P4Tools::P4Testgen::Pna::Metadata, and P4::P4Tools::P4Testgen::Pna::PTF.