P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf/backend/stf/stf.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_EBPF_BACKEND_STF_STF_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_EBPF_BACKEND_STF_STF_H_
3
4#include <cstddef>
5#include <string>
6#include <vector>
7
8#include <inja/inja.hpp>
9
10#include "lib/cstring.h"
11
12#include "backends/p4tools/modules/testgen/lib/test_framework.h"
13#include "backends/p4tools/modules/testgen/lib/test_spec.h"
14
15namespace P4::P4Tools::P4Testgen::EBPF {
16
18class STF : public TestFramework {
19 public:
20 ~STF() override = default;
21 STF(const STF &) = delete;
22 STF(STF &&) = delete;
23 STF &operator=(const STF &) = delete;
24 STF &operator=(STF &&) = delete;
25
26 explicit STF(const TestBackendConfiguration &testBackendConfiguration);
27
29 void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
30 float currentCoverage) override;
31
32 private:
38 void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
39 const std::string &testCase, float currentCoverage);
40
42 static std::string getTestCaseTemplate();
43
45 static inja::json getControlPlane(const TestSpec *testSpec);
46
48 static inja::json getSend(const TestSpec *testSpec);
49
51 static inja::json getVerify(const TestSpec *testSpec);
52
54 static inja::json getControlPlaneForTable(const TableMatchMap &matches,
55 const std::vector<ActionArg> &args);
56};
57
58} // namespace P4::P4Tools::P4Testgen::EBPF
59
60#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_EBPF_BACKEND_STF_STF_H_ */
Extracts information from the @testSpec to emit a STF test case.
Definition ebpf/backend/stf/stf.h:18
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId, float currentCoverage) override
Produce an STF test.
Definition ebpf/backend/stf/stf.cpp:233
Definition test_framework.h:54
Definition lib/test_spec.h:296
Definition cstring.h:85
Definition test_backend_configuration.h:16