1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_PROTOBUF_IR_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_PROTOBUF_IR_H_
8#include <inja/inja.hpp>
10#include "control-plane/p4RuntimeSerializer.h"
11#include "lib/cstring.h"
13#include "backends/p4tools/modules/testgen/lib/test_spec.h"
14#include "backends/p4tools/modules/testgen/targets/bmv2/test_backend/common.h"
21 std::string formattedTest_;
24 explicit ProtobufIrTest(std::string formattedTest) : formattedTest_(std::move(formattedTest)) {}
45 float currentCoverage)
override;
48 size_t testIdx,
float currentCoverage)
override;
55 [[nodiscard]] inja::json getControlPlaneTable(
const TableConfig &tblConfig)
const override;
57 [[nodiscard]] inja::json getControlPlaneForTable(
58 const TableMatchMap &matches,
const std::vector<ActionArg> &args)
const override;
60 [[nodiscard]] inja::json getSend(
const TestSpec *testSpec)
const override;
62 [[nodiscard]] inja::json getExpectedPacket(
const TestSpec *testSpec)
const override;
69 inja::json produceTestCase(
const TestSpec *testSpec,
cstring selectedBranches,
size_t testId,
70 float currentCoverage)
const;
73 static std::string getTestCaseTemplate();
77 static std::optional<std::string> checkForP4RuntimeTranslationAnnotation(
78 const IR::IAnnotated *node);
82 static std::map<cstring, cstring> getP4RuntimeTranslationMappings(
const IR::IAnnotated *node);
86 static std::string getFormatOfNode(
const IR::IAnnotated *node);
89 static std::string formatNetworkValue(
const std::string &type,
const IR::Expression *value);
92 static std::string formatNetworkValue(
const IR::IAnnotated *node,
const std::string &type,
93 const IR::Expression *value);
98 inja::json &rulesJson);
Definition p4RuntimeSerializer.h:57