Skip to content

Commit

Permalink
[P4Testgen] Hotfix for failing P4Testgen benchmark test. (#4839)
Browse files Browse the repository at this point in the history
* Hotfix for failing P4Testgen benchmark test.

Signed-off-by: fruffy <[email protected]>

* Update backends/p4tools/modules/testgen/targets/bmv2/test/testgen_api/benchmark.cpp

Co-authored-by: Vladimír Štill <[email protected]>
Signed-off-by: Fabian Ruffy <[email protected]>

---------

Signed-off-by: fruffy <[email protected]>
Signed-off-by: Fabian Ruffy <[email protected]>
Co-authored-by: Vladimír Štill <[email protected]>
  • Loading branch information
fruffy and vlstill authored Jul 31, 2024
1 parent 1a0fc15 commit fcaf633
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#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"
Expand All @@ -13,7 +16,10 @@ namespace Test {
using namespace P4::literals;

TEST(P4TestgenBenchmark, SuccessfullyGenerate1000Tests) {
auto compilerOptions = P4CContextWithOptions<CompilerOptions>::get().options();
// Set the compiler options.
auto *context = new P4Tools::CompileContext<CompilerOptions>();
AutoCompileContext autoContext(context);
auto &compilerOptions = context->options();
compilerOptions.target = "bmv2"_cs;
compilerOptions.arch = "v1model"_cs;
auto includePath = P4CTestEnvironment::getProjectRoot() / "p4include";
Expand Down
5 changes: 0 additions & 5 deletions backends/p4tools/modules/testgen/testgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <string>
#include <utility>

#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"
Expand Down Expand Up @@ -150,10 +149,6 @@ std::optional<AbstractTestList> generateTestsImpl(std::optional<std::string_view
registerTestgenTargets();
P4Tools::Target::init(compilerOptions.target.c_str(), compilerOptions.arch.c_str());

// Set up the compilation context.
auto *compileContext = new CompileContext<CompilerOptions>();
compileContext->options() = compilerOptions;
AutoCompileContext autoContext(compileContext);
CompilerResultOrError compilerResultOpt;
if (program.has_value()) {
// Run the compiler to get an IR and invoke the tool.
Expand Down

0 comments on commit fcaf633

Please sign in to comment.