From fcaf633d02afd7f02a78d9c5b6e23eec285dcb61 Mon Sep 17 00:00:00 2001 From: Fabian Ruffy <5960321+fruffy@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:44:11 +0200 Subject: [PATCH] [P4Testgen] Hotfix for failing P4Testgen benchmark test. (#4839) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Hotfix for failing P4Testgen benchmark test. Signed-off-by: fruffy * Update backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp Co-authored-by: Vladimír Štill Signed-off-by: Fabian Ruffy <5960321+fruffy@users.noreply.github.com> --------- Signed-off-by: fruffy Signed-off-by: Fabian Ruffy <5960321+fruffy@users.noreply.github.com> Co-authored-by: Vladimír Štill --- .../testgen/targets/bmv2/test/testgen_api/benchmark.cpp | 8 +++++++- backends/p4tools/modules/testgen/testgen.cpp | 5 ----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp b/backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp index 06f8074661..aab2a1bdeb 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp +++ b/backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp @@ -1,7 +1,10 @@ #include #include +#include "backends/p4tools/common/compiler/context.h" #include "backends/p4tools/common/lib/logging.h" +#include "frontends/common/options.h" +#include "lib/compile_context.h" #include "test/gtest/helpers.h" #include "backends/p4tools/modules/testgen/core/symbolic_executor/path_selection.h" @@ -13,7 +16,10 @@ namespace Test { using namespace P4::literals; TEST(P4TestgenBenchmark, SuccessfullyGenerate1000Tests) { - auto compilerOptions = P4CContextWithOptions::get().options(); + // Set the compiler options. + auto *context = new P4Tools::CompileContext(); + AutoCompileContext autoContext(context); + auto &compilerOptions = context->options(); compilerOptions.target = "bmv2"_cs; compilerOptions.arch = "v1model"_cs; auto includePath = P4CTestEnvironment::getProjectRoot() / "p4include"; diff --git a/backends/p4tools/modules/testgen/testgen.cpp b/backends/p4tools/modules/testgen/testgen.cpp index 62e9b54f59..87578e9172 100644 --- a/backends/p4tools/modules/testgen/testgen.cpp +++ b/backends/p4tools/modules/testgen/testgen.cpp @@ -7,7 +7,6 @@ #include #include -#include "backends/p4tools/common/compiler/context.h" #include "backends/p4tools/common/core/z3_solver.h" #include "frontends/common/parser_options.h" #include "ir/solver.h" @@ -150,10 +149,6 @@ std::optional generateTestsImpl(std::optional(); - compileContext->options() = compilerOptions; - AutoCompileContext autoContext(compileContext); CompilerResultOrError compilerResultOpt; if (program.has_value()) { // Run the compiler to get an IR and invoke the tool.