P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/p4tools/modules/testgen/options.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_
3
4#include <cstdint>
5#include <filesystem>
6#include <optional>
7#include <set>
8#include <string>
9
10#include "backends/p4tools/common/options.h"
11#include "lib/cstring.h"
12#include "midend/coverage.h"
13
14#include "backends/p4tools/modules/testgen/core/symbolic_executor/path_selection.h"
15
16namespace P4::P4Tools::P4Testgen {
17
20 public:
22 virtual ~TestgenOptions() = default;
23
25 int64_t maxTests = 1;
26
28 P4Testgen::PathSelectionPolicy pathSelectionPolicy = P4Testgen::PathSelectionPolicy::DepthFirst;
29
31 static const std::set<cstring> SUPPORTED_STOP_METRICS;
32
33 // Stops generating tests when a particular metric is satisfied. Currently supported options are
34 // listed in @var SUPPORTED_STOP_METRICS.
35 cstring stopMetric;
36
38 static TestgenOptions &get();
39
41 std::optional<std::filesystem::path> outputDir = std::nullopt;
42
44 bool strict = false;
45
48
50 std::string selectedBranches;
51
53 std::string pattern;
54
57 bool trackBranches = false;
58
61 bool dcg = false;
62
64 // The default is the standard MTU, 1500 bytes.
65 int maxPktSize = 12000;
66
68 int minPktSize = 0;
69
72 std::vector<std::pair<int, int>> permittedPortRanges;
73
75 std::set<cstring> skippedControlPlaneEntities;
76
78 bool outputPacketOnly = false;
79
81 bool droppedPacketOnly = false;
82
85 bool enforceAssumptions = true;
86
90
94
97 bool hasCoverageTracking = false;
98
100 float minCoverage = 0;
101
104 std::optional<cstring> testBaseName;
105
106 protected:
107 bool validateOptions() const override;
108};
109
110} // namespace P4::P4Tools::P4Testgen
111
112#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_ */
Definition backends/p4tools/common/options.h:17
Encapsulates and processes command-line options for P4Testgen.
Definition backends/p4tools/modules/testgen/options.h:19
bool droppedPacketOnly
Enforces the test generation of tests with mandatory dropped packet.
Definition backends/p4tools/modules/testgen/options.h:81
bool validateOptions() const override
Definition backends/p4tools/modules/testgen/options.cpp:421
std::optional< std::filesystem::path > outputDir
Directory for generated tests. Defaults to PWD.
Definition backends/p4tools/modules/testgen/options.h:41
std::string pattern
String of a pattern for resulting tests.
Definition backends/p4tools/modules/testgen/options.h:53
static TestgenOptions & get()
Definition backends/p4tools/modules/testgen/options.cpp:23
P4::Coverage::CoverageOptions coverageOptions
Definition backends/p4tools/modules/testgen/options.h:93
std::set< cstring > skippedControlPlaneEntities
Skip generating a control plane entry for the entities in this list.
Definition backends/p4tools/modules/testgen/options.h:75
std::string selectedBranches
String of selected branches separated by comma.
Definition backends/p4tools/modules/testgen/options.h:50
P4Testgen::PathSelectionPolicy pathSelectionPolicy
Selects the path selection policy for test generation.
Definition backends/p4tools/modules/testgen/options.h:28
bool hasCoverageTracking
Definition backends/p4tools/modules/testgen/options.h:97
bool assertionModeEnabled
Definition backends/p4tools/modules/testgen/options.h:89
std::vector< std::pair< int, int > > permittedPortRanges
Definition backends/p4tools/modules/testgen/options.h:72
cstring testBackend
The test back end that P4Testgen will generate test for. Examples are STF, PTF or Protobuf.
Definition backends/p4tools/modules/testgen/options.h:47
bool enforceAssumptions
Definition backends/p4tools/modules/testgen/options.h:85
int maxPktSize
The maximum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:65
int64_t maxTests
Maximum number of tests to be generated. Defaults to 1.
Definition backends/p4tools/modules/testgen/options.h:25
std::optional< cstring > testBaseName
Definition backends/p4tools/modules/testgen/options.h:104
static const std::set< cstring > SUPPORTED_STOP_METRICS
List of the supported stop metrics.
Definition backends/p4tools/modules/testgen/options.h:31
bool trackBranches
Definition backends/p4tools/modules/testgen/options.h:57
int minPktSize
The minimum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:68
bool outputPacketOnly
Enforces the test generation of tests with mandatory output packet.
Definition backends/p4tools/modules/testgen/options.h:78
float minCoverage
Specifies minimum coverage that needs to be achieved for P4Testgen to exit successfully.
Definition backends/p4tools/modules/testgen/options.h:100
bool strict
Fail on unimplemented features instead of trying the next branch.
Definition backends/p4tools/modules/testgen/options.h:44
bool dcg
Definition backends/p4tools/modules/testgen/options.h:61
Definition cstring.h:85
Specifies general options and which IR nodes to track with this particular visitor.
Definition coverage.h:25