7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TEST_GTEST_UTILS_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TEST_GTEST_UTILS_H_
10#include <gtest/gtest.h>
16#include "frontends/common/options.h"
18#include "lib/compile_context.h"
20#include "backends/p4tools/modules/testgen/core/target.h"
21#include "backends/p4tools/modules/testgen/register.h"
22#include "backends/p4tools/modules/testgen/toolname.h"
24namespace P4::P4Tools::Test {
27class P4ToolsTestCase {
30 static std::optional<const P4ToolsTestCase>
create(std::string deviceName, std::string archName,
31 CompilerOptions::FrontendVersion langVersion,
32 const std::string &source);
35 static std::optional<const P4ToolsTestCase>
create_14(std::string deviceName,
37 const std::string &source);
40 static std::optional<const P4ToolsTestCase>
create_16(std::string deviceName,
42 const std::string &source);
47 [[nodiscard]]
const IR::P4Program &
getProgram()
const;
55 std::reference_wrapper<const P4Tools::CompilerResult> compilerResults;
58 static void ensureInit();
63 [[nodiscard]]
static std::unique_ptr<AutoCompileContext>
SetUp(std::string_view target,
64 std::string_view archName) {
65 P4Tools::P4Testgen::registerTestgenTargets();
71 if (!ctxOpt.has_value()) {
74 return std::make_unique<AutoCompileContext>(ctxOpt.value());
81 const IR::SymbolicVariable *preorder(IR::Member *member)
override;