1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_PROTOBUF_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TEST_BACKEND_PROTOBUF_H_
9#include <inja/inja.hpp>
11#include "backends/p4tools/common/control_plane/p4info_map.h"
12#include "control-plane/p4RuntimeSerializer.h"
14#include "lib/cstring.h"
16#include "backends/p4tools/modules/testgen/lib/test_spec.h"
17#include "backends/p4tools/modules/testgen/targets/bmv2/test_backend/common.h"
21using P4::ControlPlaneAPI::p4rt_id_t;
26 std::string formattedTest_;
29 explicit ProtobufTest(std::string formattedTest) : formattedTest_(std::move(formattedTest)) {}
44 float currentCoverage)
override;
47 size_t testIdx,
float currentCoverage)
override;
57 inja::json getControlPlane(
const TestSpec *testSpec)
const override;
59 [[nodiscard]] inja::json getSend(
const TestSpec *testSpec)
const override;
61 [[nodiscard]] inja::json getExpectedPacket(
const TestSpec *testSpec)
const override;
64 static std::string formatHexExprWithSep(
const IR::Expression *expr);
68 [[nodiscard]] std::optional<p4rt_id_t> lookupP4RuntimeId(
cstring controlPlaneName)
const;
72 void emitPreamble(
const std::string &preamble);
79 inja::json produceTestCase(
const TestSpec *testSpec,
cstring selectedBranches,
size_t testId,
80 float currentCoverage)
const;
83 static std::string getTestCaseTemplate();
88 [[nodiscard]] inja::json getControlPlaneForTable(
cstring tableName,
cstring actionName,
89 const TableMatchMap &matches,
90 const std::vector<ActionArg> &args)
const;
Definition p4info_map.h:37
Definition p4RuntimeSerializer.h:57