P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf/backend/stf/stf.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_TARGETS_EBPF_BACKEND_STF_STF_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_EBPF_BACKEND_STF_STF_H_
9
10#include <cstddef>
11#include <string>
12#include <vector>
13
14#include <inja/inja.hpp>
15
16#include "lib/cstring.h"
17
18#include "backends/p4tools/modules/testgen/lib/test_framework.h"
19#include "backends/p4tools/modules/testgen/lib/test_spec.h"
20
21namespace P4::P4Tools::P4Testgen::EBPF {
22
24class STF : public TestFramework {
25 public:
26 ~STF() override = default;
27 STF(const STF &) = delete;
28 STF(STF &&) = delete;
29 STF &operator=(const STF &) = delete;
30 STF &operator=(STF &&) = delete;
31
32 explicit STF(const TestBackendConfiguration &testBackendConfiguration);
33
35 void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
36 float currentCoverage) override;
37
38 private:
44 void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
45 const std::string &testCase, float currentCoverage);
46
48 static std::string getTestCaseTemplate();
49
51 static inja::json getControlPlane(const TestSpec *testSpec);
52
54 static inja::json getSend(const TestSpec *testSpec);
55
57 static inja::json getVerify(const TestSpec *testSpec);
58
60 static inja::json getControlPlaneForTable(const TableMatchMap &matches,
61 const std::vector<ActionArg> &args);
62};
63
64} // namespace P4::P4Tools::P4Testgen::EBPF
65
66#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_EBPF_BACKEND_STF_STF_H_ */
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId, float currentCoverage) override
Produce an STF test.
Definition ebpf/backend/stf/stf.cpp:237
TestFramework(const TestBackendConfiguration &testBackendConfiguration)
Creates a generic test framework.
Definition test_framework.cpp:11
Definition lib/test_spec.h:303
Definition cstring.h:85
Definition test_backend_configuration.h:22