P4C
The P4 Compiler
Loading...
Searching...
No Matches
common.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_COMMON_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_COMMON_H_
3
4#include <filesystem>
5#include <optional>
6#include <vector>
7
8#include <inja/inja.hpp>
9
10#include "backends/p4tools/modules/testgen/lib/test_framework.h"
11#include "backends/p4tools/modules/testgen/lib/test_object.h"
12#include "backends/p4tools/modules/testgen/lib/test_spec.h"
13
15
18 public:
19 explicit Bmv2TestFramework(const TestBackendConfiguration &testBackendConfiguration);
20
21 protected:
23 static std::string formatHexExpressionWithSeparators(const IR::Expression &expr);
24
26 virtual inja::json getControlPlane(const TestSpec *testSpec) const;
27
29 [[nodiscard]] virtual inja::json getClone(const TestObjectMap &cloneSpecs) const;
30
32 [[nodiscard]] virtual inja::json::array_t getMeter(const TestObjectMap &meterValues) const;
33
35 [[nodiscard]] virtual inja::json getControlPlaneTable(const TableConfig &tblConfig) const;
36
38 [[nodiscard]] virtual inja::json getControlPlaneForTable(
39 const TableMatchMap &matches, const std::vector<ActionArg> &args) const;
40
42 virtual inja::json getSend(const TestSpec *testSpec) const;
43
45 virtual inja::json getExpectedPacket(const TestSpec *testSpec) const;
46};
47} // namespace P4::P4Tools::P4Testgen::Bmv2
48
49#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_COMMON_H_ */
Bmv2TestFramework provides common utility functions for BMv2-style test frameworks.
Definition common.h:17
static std::string formatHexExpressionWithSeparators(const IR::Expression &expr)
Wrapper helper function that automatically inserts separators for hex strings.
Definition common.cpp:25
virtual inja::json::array_t getMeter(const TestObjectMap &meterValues) const
Definition common.cpp:47
virtual inja::json getControlPlaneTable(const TableConfig &tblConfig) const
Converts a table configuration into Inja format.
Definition common.cpp:69
virtual inja::json getExpectedPacket(const TestSpec *testSpec) const
Converts the output packet, port, and mask into Inja format.
Definition common.cpp:191
virtual inja::json getControlPlaneForTable(const TableMatchMap &matches, const std::vector< ActionArg > &args) const
Helper function for the control plane table inja objects.
Definition common.cpp:117
virtual inja::json getControlPlane(const TestSpec *testSpec) const
Converts all the control plane objects into Inja format.
Definition common.cpp:88
virtual inja::json getClone(const TestObjectMap &cloneSpecs) const
Returns the configuration for a cloned packet configuration.
Definition common.cpp:29
virtual inja::json getSend(const TestSpec *testSpec) const
Converts the input packet and port into Inja format.
Definition common.cpp:180
Definition lib/test_spec.h:253
Definition test_framework.h:54
Definition lib/test_spec.h:296
Inja.
Definition targets/bmv2/cmd_stepper.cpp:33
Definition test_backend_configuration.h:16