P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino_gtest_utils.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_TEST_GTEST_TOFINO_GTEST_UTILS_H_
20#define BACKENDS_TOFINO_BF_P4C_TEST_GTEST_TOFINO_GTEST_UTILS_H_
21
22#include <optional>
23#include <string>
24
25#include "bf-p4c/arch/arch.h"
26#include "bf-p4c/bf-p4c-options.h"
27#include "bf-p4c/device.h"
28#include "gtest/gtest.h"
29#include "lib/compile_context.h"
30
31namespace P4 {
32namespace IR {
33namespace BFN {
34class Pipe;
35} // namespace BFN
36class P4Program;
37} // namespace IR
38} // namespace P4
39
40namespace P4::Test {
41
42const char *tna_header();
43const char *t2na_header();
44
47 static std::optional<MidendTestCase> create(const std::string &source);
48
50 const IR::P4Program *program;
51
53 const IR::P4Program *frontendProgram;
54};
55
58 static std::optional<TofinoPipeTestCase> create(const std::string &source);
59
62 static std::optional<TofinoPipeTestCase> createWithThreadLocalInstances(
63 const std::string &source);
64
66 const IR::BFN::Pipe *pipe;
67
69 const IR::P4Program *frontendProgram;
70};
71
73class BackendTest : public ::testing::Test {
74 protected:
75 BackendTest() : autoBFNContext(new BFNContext()) {}
76
77 AutoCompileContext autoBFNContext;
78};
79
82 public:
83 TofinoBackendTest() { Device::init("Tofino"_cs); }
84};
85
88 public:
89 JBayBackendTest() { Device::init("Tofino2"_cs); }
90};
91
92} // namespace P4::Test
93
94#endif /* BACKENDS_TOFINO_BF_P4C_TEST_GTEST_TOFINO_GTEST_UTILS_H_ */
A CompileContext for bf-p4c.
Definition bf-p4c-options.h:136
static void init(cstring name)
Definition device.cpp:28
A GTest fixture base class for backend targets.
Definition tofino_gtest_utils.h:73
A GTest fixture for JBay tests.
Definition tofino_gtest_utils.h:87
A GTest fixture for Tofino tests.
Definition tofino_gtest_utils.h:81
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
The namespace encapsulating IR node classes.
Definition json.h:34
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition compile_context.h:77
Definition tofino_gtest_utils.h:45
const IR::P4Program * program
The output of the midend.
Definition tofino_gtest_utils.h:50
static std::optional< MidendTestCase > create(const std::string &source)
Create a test case that requires the frontend and the midend to run.
Definition tofino_gtest_utils.cpp:50
const IR::P4Program * frontendProgram
The output of the frontend.
Definition tofino_gtest_utils.h:53
Definition tofino_gtest_utils.h:56
const IR::BFN::Pipe * pipe
The output of extract_maupipe().
Definition tofino_gtest_utils.h:66
const IR::P4Program * frontendProgram
The output of the frontend.
Definition tofino_gtest_utils.h:69
static std::optional< TofinoPipeTestCase > create(const std::string &source)
Create a test case that requires extract_maupipe() to run.
Definition tofino_gtest_utils.cpp:75
static std::optional< TofinoPipeTestCase > createWithThreadLocalInstances(const std::string &source)
Definition tofino_gtest_utils.cpp:119