-
Notifications
You must be signed in to change notification settings - Fork 441
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
Support header and struct for logging (fixes #2201) #2596
base: main
Are you sure you want to change the base?
Conversation
I think the prerequisite might be best described in the other direction. That is, until the corresponding changes to p4lang/behavioral-model repository are approved and merged in, it is undesirable to merge these changes to p4c. |
|
||
Header hdr1 = {3,-1,true}; | ||
log_msg("hdr1 = {}",{hdr1}); | ||
// Output: hdr1 = {'val1': 3, 'val2': -1, 'val3': 1, '$valid$': 1} |
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 know there is currently no convenient way to automate the checking of the log message output in p4c's automated tests, but even so, I think it would be good to add a call to log_msg() on a header that is currently invalid, to at least test that this doesn't cause behavioral-model to crash.
This is very nice. Hopefully more architectures will support this. |
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.
Still, is there any reason not to merge this? No tests we have are impacted.
I guess the test program does not have a name ending in '-bmv2.p4' and thus will not run bmv2 with the compiled output of this program as input. It seems best for long term slightly better test coverage if it did run bmv2. If so, then merging these changes should wait for the corresponding p4lang/behavioral-model merge, plus enough hours for that to be used for p4lang/p4c automated tests. |
Changing the condition enabled to json file generation. This is a prerequest for the execution of behavioral-model, where other changed were made. Example 1: header Hdr { int<4> a; bit<4> b; } Hdr h = {3,5}; log_msg("h = {}", {h}); Output: h = {'a': 3, 'b': 5, '$valid$': 1} Example 2: struct Str { int<4> a; bit<4> b; bool c; } Str s = {3,5,true}; log_msg("s = {}", {s}); Output: s = {'a': 3, 'b': 5, 'c': 1}
On my local machine (Linux, Ubuntu 18.04) all tests are passing, same as for macOS on Travis. Can you possibly help me interpret why those two tests which I added fail, on Linux on Travis, with message: |
What happens when you run this on your machine: |
Why close the PR? |
This is the output: |
It looks like Travis is running a different version of bmv2. I think it rebuilds a new one periodically, so perhaps it does not yet have all changes made in that repo? |
Ah, yes, as soon as bmv2 PR p4lang/behavioral-model#962 is merged into bmv2 tests should pass. Thank you! |
Changing the condition enabled to json file generation. This is a prerequisite for the execution of behavioral-model, where other changed were made. This PR is related to p4lang/behavioral-model#962 PR in behavioral-model.