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:
21 virtual ~TestgenOptions() = default;
22
24 int64_t maxTests = 1;
25
27 P4Testgen::PathSelectionPolicy pathSelectionPolicy = P4Testgen::PathSelectionPolicy::DepthFirst;
28
30 static const std::set<cstring> SUPPORTED_STOP_METRICS;
31
32 // Stops generating tests when a particular metric is satisfied. Currently supported options are
33 // listed in @var SUPPORTED_STOP_METRICS.
34 cstring stopMetric;
35
37 static TestgenOptions &get();
38
40 std::optional<std::filesystem::path> outputDir = std::nullopt;
41
43 bool strict = false;
44
47
49 std::string selectedBranches;
50
52 std::string pattern;
53
56 bool trackBranches = false;
57
60 bool dcg = false;
61
63 // The default is the standard MTU, 1500 bytes.
64 int maxPktSize = 12000;
65
67 int minPktSize = 0;
68
71 std::vector<std::pair<int, int>> permittedPortRanges;
72
74 std::set<cstring> skippedControlPlaneEntities;
75
77 bool outputPacketOnly = false;
78
80 bool droppedPacketOnly = false;
81
84 bool enforceAssumptions = true;
85
89
93
96 bool hasCoverageTracking = false;
97
99 float minCoverage = 0;
100
103 std::optional<cstring> testBaseName;
104
105 const char *getIncludePath() const override;
106
107 protected:
108 bool validateOptions() const override;
109
110 private:
112};
113
114} // namespace P4::P4Tools::P4Testgen
115
116#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_ */
Definition backends/p4tools/common/options.h:18
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:80
bool validateOptions() const override
Definition backends/p4tools/modules/testgen/options.cpp:428
std::optional< std::filesystem::path > outputDir
Directory for generated tests. Defaults to PWD.
Definition backends/p4tools/modules/testgen/options.h:40
std::string pattern
String of a pattern for resulting tests.
Definition backends/p4tools/modules/testgen/options.h:52
static TestgenOptions & get()
Definition backends/p4tools/modules/testgen/options.cpp:22
P4::Coverage::CoverageOptions coverageOptions
Definition backends/p4tools/modules/testgen/options.h:92
std::set< cstring > skippedControlPlaneEntities
Skip generating a control plane entry for the entities in this list.
Definition backends/p4tools/modules/testgen/options.h:74
std::string selectedBranches
String of selected branches separated by comma.
Definition backends/p4tools/modules/testgen/options.h:49
P4Testgen::PathSelectionPolicy pathSelectionPolicy
Selects the path selection policy for test generation.
Definition backends/p4tools/modules/testgen/options.h:27
bool hasCoverageTracking
Definition backends/p4tools/modules/testgen/options.h:96
bool assertionModeEnabled
Definition backends/p4tools/modules/testgen/options.h:88
std::vector< std::pair< int, int > > permittedPortRanges
Definition backends/p4tools/modules/testgen/options.h:71
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:46
bool enforceAssumptions
Definition backends/p4tools/modules/testgen/options.h:84
int maxPktSize
The maximum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:64
int64_t maxTests
Maximum number of tests to be generated. Defaults to 1.
Definition backends/p4tools/modules/testgen/options.h:24
std::optional< cstring > testBaseName
Definition backends/p4tools/modules/testgen/options.h:103
static const std::set< cstring > SUPPORTED_STOP_METRICS
List of the supported stop metrics.
Definition backends/p4tools/modules/testgen/options.h:30
bool trackBranches
Definition backends/p4tools/modules/testgen/options.h:56
int minPktSize
The minimum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:67
bool outputPacketOnly
Enforces the test generation of tests with mandatory output packet.
Definition backends/p4tools/modules/testgen/options.h:77
float minCoverage
Specifies minimum coverage that needs to be achieved for P4Testgen to exit successfully.
Definition backends/p4tools/modules/testgen/options.h:99
bool strict
Fail on unimplemented features instead of trying the next branch.
Definition backends/p4tools/modules/testgen/options.h:43
bool dcg
Definition backends/p4tools/modules/testgen/options.h:60
Definition cstring.h:85
Specifies general options and which IR nodes to track with this particular visitor.
Definition coverage.h:25