-
Notifications
You must be signed in to change notification settings - Fork 397
Minimal e2e implementation of packet trace. #1433
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
Open
c8ef
wants to merge
8
commits into
p4lang:main
Choose a base branch
from
c8ef:next
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c82470
minimal MVP
c8ef b6dd50c
Merge branch 'main' into next
c8ef 350877b
git rid of auto type
c8ef 1339367
tweak test
c8ef e5ebb0e
refine
c8ef 50cef99
rename hex_dump
c8ef 528a27c
simplify wait traces
c8ef 83437df
rename packet trace
c8ef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # SPDX-FileCopyrightText: 2026 Yuao Ma | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| load("@gutil//gutil:diff_test.bzl", "cmd_diff_test") | ||
| load("@rules_cc//cc:cc_binary.bzl", "cc_binary") | ||
|
|
||
| package( | ||
| default_visibility = ["//visibility:public"], | ||
| licenses = ["notice"], | ||
| ) | ||
|
|
||
| cc_binary( | ||
| name = "test_packet_trace", | ||
| testonly = True, | ||
| srcs = ["test_packet_trace.cpp"], | ||
| deps = [ | ||
| "//:bm_headers", | ||
| "//proto:packet_trace_cc_proto", | ||
| "//src/bm_sim:bmsim", | ||
| "//targets/simple_switch:simpleswitch", | ||
| "@com_google_protobuf//:protobuf", | ||
| ], | ||
| ) | ||
|
|
||
| # One golden test per P4 pipeline: the runner sends the pipeline's scenario | ||
| # packets through an in-process simple_switch and prints the resulting packet | ||
| # traces; the output is diffed against the checked-in testdata/<pipeline>.trace | ||
| # file. To regenerate a golden file: | ||
| # bazel run <test target> -- --update | ||
| _PACKET_TRACE_GOLDEN_PIPELINES = [ | ||
| "packet_redirect", | ||
| "parser_error", | ||
| "queueing", | ||
| "recirc", | ||
| "truncate", | ||
| ] | ||
|
|
||
| [ | ||
| cmd_diff_test( | ||
| name = "packet_trace_%s_diff_test" % pipeline, | ||
| actual_cmd = "$(execpath :test_packet_trace) %s $(location testdata/%s.json)" % (pipeline, pipeline), | ||
| data = ["testdata/%s.json" % pipeline], | ||
| expected = "testdata/%s.trace" % pipeline, | ||
| tools = [":test_packet_trace"], | ||
| ) | ||
| for pipeline in _PACKET_TRACE_GOLDEN_PIPELINES | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My one request is also to add test support for cmake here. Bazel-only is not great for the wider community
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR is already huge I suggest this could be done in follow up PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to merge this only when it is complete. This PR only changes 19 files, most of which are test files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. But I'm not familiar with all these build systems so it might take a while.