P4C
The P4 Compiler
Loading...
Searching...
No Matches
bmv2/test_backend/stf.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_STF_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_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_spec.h"
13#include "backends/p4tools/modules/testgen/targets/bmv2/test_backend/common.h"
14
16
18class STF : public Bmv2TestFramework {
19 public:
20 explicit STF(const TestBackendConfiguration &testBackendConfiguration);
21
23 void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId,
24 float currentCoverage) override;
25
26 private:
32 void emitTestcase(const TestSpec *testSpec, cstring selectedBranches, size_t testId,
33 const std::string &testCase, float currentCoverage);
34
36 static std::string getTestCaseTemplate();
37
38 inja::json getExpectedPacket(const TestSpec *testSpec) const override;
39
41 inja::json getSend(const TestSpec *testSpec) const override;
42
43 inja::json getControlPlaneForTable(const TableMatchMap &matches,
44 const std::vector<ActionArg> &args) const override;
45};
46
47} // namespace P4::P4Tools::P4Testgen::Bmv2
48
49#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_STF_H_ */
Bmv2TestFramework provides common utility functions for BMv2-style test frameworks.
Definition common.h:17
Extracts information from the @testSpec to emit a STF test case.
Definition bmv2/test_backend/stf.h:18
void writeTestToFile(const TestSpec *spec, cstring selectedBranches, size_t testId, float currentCoverage) override
Produce an STF test.
Definition bmv2/test_backend/stf.cpp:198
Definition lib/test_spec.h:296
Definition cstring.h:85
Inja.
Definition targets/bmv2/cmd_stepper.cpp:33
Definition test_backend_configuration.h:16