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

Encapsulates and processes command-line options for P4Testgen. More...

#include <options.h>

Inheritance diagram for P4::P4Tools::P4Testgen::TestgenOptions:
[legend]

Public Member Functions

const char * getIncludePath () const override
 
- Public Member Functions inherited from P4::P4Tools::AbstractP4cToolOptions
std::optional< ICompileContext * > process (const std::vector< const char * > &args)
 
std::vector< const char * > * process (int argc, char *const argv[]) override
 Hook for customizing options processing.
 

Static Public Member Functions

static TestgenOptionsget ()
 

Public Attributes

bool assertionModeEnabled = false
 
P4::Coverage::CoverageOptions coverageOptions
 
bool dcg = false
 
bool droppedPacketOnly = false
 Enforces the test generation of tests with mandatory dropped packet.
 
bool enforceAssumptions = true
 
bool hasCoverageTracking = false
 
int maxPktSize = 12000
 The maximum permitted packet size, in bits.
 
int64_t maxTests = 1
 Maximum number of tests to be generated. Defaults to 1.
 
float minCoverage = 0
 Specifies minimum coverage that needs to be achieved for P4Testgen to exit successfully.
 
int minPktSize = 0
 The minimum permitted packet size, in bits.
 
std::optional< std::filesystem::path > outputDir = std::nullopt
 Directory for generated tests. Defaults to PWD.
 
bool outputPacketOnly = false
 Enforces the test generation of tests with mandatory output packet.
 
P4Testgen::PathSelectionPolicy pathSelectionPolicy = P4Testgen::PathSelectionPolicy::DepthFirst
 Selects the path selection policy for test generation.
 
std::string pattern
 String of a pattern for resulting tests.
 
std::vector< std::pair< int, int > > permittedPortRanges
 
std::string selectedBranches
 String of selected branches separated by comma.
 
std::set< cstringskippedControlPlaneEntities
 Skip generating a control plane entry for the entities in this list.
 
cstring stopMetric
 
bool strict = false
 Fail on unimplemented features instead of trying the next branch.
 
cstring testBackend
 The test back end that P4Testgen will generate test for. Examples are STF, PTF or Protobuf.
 
std::optional< cstringtestBaseName
 
bool trackBranches = false
 
- Public Attributes inherited from P4::P4Tools::AbstractP4cToolOptions
std::vector< const char * > compilerArgs
 Command-line arguments to be sent to the compiler. Populated by @process.
 
bool disableInformationLogging = false
 Disable information logging.
 
std::optional< uint32_t > seed = std::nullopt
 A seed for the PRNG.
 

Static Public Attributes

static const std::set< cstringSUPPORTED_STOP_METRICS = {"MAX_NODE_COVERAGE"_cs}
 List of the supported stop metrics.
 

Protected Member Functions

bool validateOptions () const override
 
- Protected Member Functions inherited from P4::P4Tools::AbstractP4cToolOptions
 AbstractP4cToolOptions (AbstractP4cToolOptions &&)=default
 
 AbstractP4cToolOptions (const AbstractP4cToolOptions &)=default
 
 AbstractP4cToolOptions (std::string_view toolName, std::string_view message)
 
const std::string & getToolName () const
 The name of the tool associated with these options.
 
AbstractP4cToolOptionsoperator= (const AbstractP4cToolOptions &)=default
 
- Protected Member Functions inherited from P4::Util::Options
 Options (std::string_view message)
 
void registerOption (const char *option, const char *argName, OptionProcessor processor, const char *description, OptionFlags flags=OptionFlags::Default)
 
void registerUsage (const char *msg)
 
void setOutStream (std::ostream *out)
 
cstring getBinaryName ()
 
cstring getBuildDate ()
 
cstring getCompileCommand ()
 
virtual void usage ()
 

Additional Inherited Members

- Protected Types inherited from P4::Util::Options
enum  OptionFlags { Default = 0 , Hide = 1 << 0 , OptionalArgument = 1 << 1 }
 
using OptionProcessor = std::function<bool(const char *)>
 
- Static Protected Member Functions inherited from P4::P4Tools::AbstractP4cToolOptions
static std::tuple< int, char ** > convertArgs (const std::vector< const char * > &args)
 Converts a vector of command-line arguments into the traditional (argc, argv) format.
 
- Protected Attributes inherited from P4::Util::Options
std::vector< const char * > additionalUsage
 
const char * binaryName
 
cstring buildDate
 
bool collectUnknownOptions = false
 
cstring compileCommand
 
cstring message
 
std::vector< cstringoptionOrder
 
std::map< cstring, const Option * > options
 
std::ostream * outStream = &std::cerr
 
std::vector< const char * > remainingOptions
 

Detailed Description

Encapsulates and processes command-line options for P4Testgen.

Member Function Documentation

◆ get()

TestgenOptions & P4::P4Tools::P4Testgen::TestgenOptions::get ( )
static
Returns
the singleton instance of this class.

◆ getIncludePath()

const char * P4::P4Tools::P4Testgen::TestgenOptions::getIncludePath ( ) const
overridevirtual

Implements P4::Util::Options.

◆ validateOptions()

bool P4::P4Tools::P4Testgen::TestgenOptions::validateOptions ( ) const
overrideprotectedvirtual

Checks if parsed options make sense with respect to each-other.

Returns
true if the validation was successful and false otherwise.

Reimplemented from P4::P4Tools::AbstractP4cToolOptions.

Member Data Documentation

◆ assertionModeEnabled

bool P4::P4Tools::P4Testgen::TestgenOptions::assertionModeEnabled = false

Produce only tests that violate the condition defined in assert calls. This will either produce no tests or only tests that contain counter examples.

◆ coverageOptions

P4::Coverage::CoverageOptions P4::P4Tools::P4Testgen::TestgenOptions::coverageOptions

Specifies general options which IR nodes to track for coverage in the targeted P4 program. Multiple options are possible. Currently supported: STATEMENTS, TABLE_ENTRIES.

◆ dcg

bool P4::P4Tools::P4Testgen::TestgenOptions::dcg = false

Build a DCG for input program. This control flow graph directed cyclic graph can be used for statement reachability analysis.

◆ enforceAssumptions

bool P4::P4Tools::P4Testgen::TestgenOptions::enforceAssumptions = true

Add conditions defined in assert/assume to the path conditions. Only tests which satisfy these conditions can be generated. This is active by default.

◆ hasCoverageTracking

bool P4::P4Tools::P4Testgen::TestgenOptions::hasCoverageTracking = false

Indicates that coverage tracking is enabled for some coverage criteria. This is used for sanity checking and it also affects information printed to output.

◆ permittedPortRanges

std::vector<std::pair<int, int> > P4::P4Tools::P4Testgen::TestgenOptions::permittedPortRanges

The list of permitted port ranges. TestGen will consider these when choosing input and output ports.

◆ testBaseName

std::optional<cstring> P4::P4Tools::P4Testgen::TestgenOptions::testBaseName

The base name of the tests which are generated. Defaults to the name of the input program, if provided.

◆ trackBranches

bool P4::P4Tools::P4Testgen::TestgenOptions::trackBranches = false

Track the branches that are executed in the symbolic executor. This can be used for deterministic replay of an execution trace.