Skip to content

Commit

Permalink
[P4Testgen] Initialize the testgen targets when invoking the library …
Browse files Browse the repository at this point in the history
…API (p4lang#4706)

* Register P4Testgen targets to fix library invocation.

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

* Also ensure that the returned tests are not null.

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

---------

Signed-off-by: fruffy <[email protected]>
  • Loading branch information
fruffy authored Jul 27, 2024
1 parent 2319fc4 commit 4c25ea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ TEST(P4TestgenBenchmark, SuccessfullyGenerate1000Tests) {
// This enables performance printing.
P4Tools::enablePerformanceLogging();

P4Tools::P4Testgen::Testgen::generateTests(compilerOptions, testgenOptions);
auto testList = P4Tools::P4Testgen::Testgen::generateTests(compilerOptions, testgenOptions);
ASSERT_TRUE(testList.has_value());

// Print the report.
P4Tools::printPerformanceReport();
Expand Down
1 change: 1 addition & 0 deletions backends/p4tools/modules/testgen/testgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ std::optional<AbstractTestList> generateTestsImpl(std::optional<std::string_view
const CompilerOptions &compilerOptions,
const TestgenOptions &testgenOptions,
bool writeTests) {
registerTestgenTargets();
P4Tools::Target::init(compilerOptions.target.c_str(), compilerOptions.arch.c_str());

// Set up the compilation context.
Expand Down

0 comments on commit 4c25ea5

Please sign in to comment.