forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstf.h
More file actions
55 lines (40 loc) · 2.11 KB
/
stf.h
File metadata and controls
55 lines (40 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_PNA_BACKEND_STF_STF_H_
#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_PNA_BACKEND_STF_STF_H_
#include <cstddef>
#include <string>
#include <vector>
#include <inja/inja.hpp>
#include "lib/cstring.h"
#include "backends/p4tools/modules/testgen/lib/test_framework.h"
#include "backends/p4tools/modules/testgen/lib/test_object.h"
#include "backends/p4tools/modules/testgen/lib/test_spec.h"
namespace P4::P4Tools::P4Testgen::Pna {
/// Extracts information from the @testSpec to emit an STF test case.
class STF : public TestFramework {
public:
explicit STF(const TestBackendConfiguration &testBackendConfiguration);
/// Produce an STF test.
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
float currentCoverage) override;
private:
/// Emits a test case.
/// @param testId specifies the test name.
/// @param selectedBranches enumerates the choices the interpreter made for this path.
/// @param currentCoverage contains statistics about the current coverage of this test and its
/// preceding tests.
void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
const std::string &testCase, float currentCoverage);
/// @returns the inja test case template as a string.
static std::string getTestCaseTemplate();
/// Converts all the control plane objects into Inja format.
static inja::json getControlPlane(const TestSpec *testSpec);
/// Converts the input packet and port into Inja format.
static inja::json getSend(const TestSpec *testSpec);
/// Converts the output packet, port, and mask into Inja format.
static inja::json getExpectedPacket(const TestSpec *testSpec);
/// Helper function for the control plane table inja objects.
static inja::json getControlPlaneForTable(const TableMatchMap &matches,
const std::vector<ActionArg> &args);
};
} // namespace P4::P4Tools::P4Testgen::Pna
#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_PNA_BACKEND_STF_STF_H_ */