Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure P4Tools to easily add new modules. #3646

Merged
merged 4 commits into from
Nov 22, 2022
Merged

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Oct 31, 2022

This PR restructures P4Tools such that it is easier to add new modules to the framework. The PR removes the p4check binary and instead adds a binary per module. This means, instead of p4check testgen one can now call p4testgen directly.

To add a new module, a folder inside p4tools/modules with a corresponding CMakelists file needs to be created. The CMake script should pick this up directly.

@fruffy fruffy marked this pull request as ready for review October 31, 2022 16:09
@fruffy fruffy changed the title Restruct P4Tools to easily add new modules. Restructure P4Tools to easily add new modules. Oct 31, 2022
@fruffy fruffy force-pushed the fruffy/remove_p4check branch 6 times, most recently from bceeb92 to 11aa399 Compare November 10, 2022 22:08
@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Nov 12, 2022
${TESTGEN_LIBS}
)

add_p4tools_executable(p4testgen main.cpp)

target_link_libraries(
p4testgen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should p4testgen be removed?


try {
P4Tools::P4Testgen::Testgen().main(args);
} catch (const Util::CompilerBug& e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a util function and replace CompilerBug to ToolsBug, TestgenBug or something (not in this PR).

@@ -3,7 +3,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../../cmake/TestUtils.cmake)
# Add v1model tests from the p4c submodule
set(P4TOOLS_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(P4TESTGEN_DIR ${CMAKE_SOURCE_DIR}/build/testgen)
set(P4TESTGEN_DRIVER "${P4TOOLS_BINARY_DIR}/p4check testgen")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So p4check doesn't exist at all now. Any module needs to be invoked via it's name like p4testgen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, after this PR p4check does not exist any more. All tests are run with the p4testgen binary.

Copy link
Contributor

@pkotikal pkotikal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@fruffy fruffy merged commit 9e33f88 into main Nov 22, 2022
@fruffy fruffy deleted the fruffy/remove_p4check branch November 23, 2022 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants