P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/p4tools/modules/testgen/options.h
1/*
2 * SPDX-FileCopyrightText: 2022 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_
9
10#include <cstdint>
11#include <filesystem>
12#include <optional>
13#include <set>
14#include <string>
15
16#include "backends/p4tools/common/options.h"
17#include "lib/cstring.h"
18#include "midend/coverage.h"
19
20#include "backends/p4tools/modules/testgen/core/symbolic_executor/path_selection.h"
21
22namespace P4::P4Tools::P4Testgen {
23
25class TestgenOptions : public AbstractP4cToolOptions {
26 public:
27 TestgenOptions();
28 virtual ~TestgenOptions() = default;
29
31 int64_t maxTests = 1;
32
34 P4Testgen::PathSelectionPolicy pathSelectionPolicy = P4Testgen::PathSelectionPolicy::DepthFirst;
35
37 static const std::set<cstring> SUPPORTED_STOP_METRICS;
38
39 // Stops generating tests when a particular metric is satisfied. Currently supported options are
40 // listed in @var SUPPORTED_STOP_METRICS.
41 cstring stopMetric;
42
44 static TestgenOptions &get();
45
47 std::optional<std::filesystem::path> outputDir = std::nullopt;
48
50 bool strict = false;
51
54
56 std::string selectedBranches;
57
59 std::string pattern;
60
63 bool trackBranches = false;
64
67 bool dcg = false;
68
70 // The default is the standard MTU, 1500 bytes.
71 int maxPktSize = 12000;
72
74 int minPktSize = 0;
75
78 std::vector<std::pair<int, int>> permittedPortRanges;
79
81 std::set<cstring> skippedControlPlaneEntities;
82
84 bool outputPacketOnly = false;
85
87 bool droppedPacketOnly = false;
88
91 bool enforceAssumptions = true;
92
96
101
105
107 float minCoverage = 0;
108
111 std::optional<cstring> testBaseName;
112
113 protected:
114 bool validateOptions() const override;
115};
116
117} // namespace P4::P4Tools::P4Testgen
118
119#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_OPTIONS_H_ */
bool droppedPacketOnly
Enforces the test generation of tests with mandatory dropped packet.
Definition backends/p4tools/modules/testgen/options.h:87
bool validateOptions() const override
Definition backends/p4tools/modules/testgen/options.cpp:430
std::optional< std::filesystem::path > outputDir
Directory for generated tests. Defaults to PWD.
Definition backends/p4tools/modules/testgen/options.h:47
std::string pattern
String of a pattern for resulting tests.
Definition backends/p4tools/modules/testgen/options.h:59
static TestgenOptions & get()
Definition backends/p4tools/modules/testgen/options.cpp:27
P4::Coverage::CoverageOptions coverageOptions
Definition backends/p4tools/modules/testgen/options.h:100
std::set< cstring > skippedControlPlaneEntities
Skip generating a control plane entry for the entities in this list.
Definition backends/p4tools/modules/testgen/options.h:81
std::string selectedBranches
String of selected branches separated by comma.
Definition backends/p4tools/modules/testgen/options.h:56
P4Testgen::PathSelectionPolicy pathSelectionPolicy
Selects the path selection policy for test generation.
Definition backends/p4tools/modules/testgen/options.h:34
bool hasCoverageTracking
Definition backends/p4tools/modules/testgen/options.h:104
bool assertionModeEnabled
Definition backends/p4tools/modules/testgen/options.h:95
std::vector< std::pair< int, int > > permittedPortRanges
Definition backends/p4tools/modules/testgen/options.h:78
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:53
bool enforceAssumptions
Definition backends/p4tools/modules/testgen/options.h:91
int maxPktSize
The maximum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:71
int64_t maxTests
Maximum number of tests to be generated. Defaults to 1.
Definition backends/p4tools/modules/testgen/options.h:31
std::optional< cstring > testBaseName
Definition backends/p4tools/modules/testgen/options.h:111
static const std::set< cstring > SUPPORTED_STOP_METRICS
List of the supported stop metrics.
Definition backends/p4tools/modules/testgen/options.h:37
bool trackBranches
Definition backends/p4tools/modules/testgen/options.h:63
int minPktSize
The minimum permitted packet size, in bits.
Definition backends/p4tools/modules/testgen/options.h:74
bool outputPacketOnly
Enforces the test generation of tests with mandatory output packet.
Definition backends/p4tools/modules/testgen/options.h:84
float minCoverage
Specifies minimum coverage that needs to be achieved for P4Testgen to exit successfully.
Definition backends/p4tools/modules/testgen/options.h:107
bool strict
Fail on unimplemented features instead of trying the next branch.
Definition backends/p4tools/modules/testgen/options.h:50
bool dcg
Definition backends/p4tools/modules/testgen/options.h:67
Definition cstring.h:85
Specifies general options and which IR nodes to track with this particular visitor.
Definition coverage.h:31