-
Notifications
You must be signed in to change notification settings - Fork 444
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
[P4Testgen] Generate NoMatch for selects without default #4250
Conversation
Could you add an example program that exhibits this problem? Just so I can verify myself. I need to check whether this complies with P4 specification behavior |
@fruffy, I've modified one of the BMV2 examples for this: bmv2_parse_nomatch.p4. This is the result of testgen with this branch:
The test 3 is the one with NoMatch. with
… the NoMatch test is missing. |
This is the generated test that is missing in main: bmv2_parse_nomatch_3.stf. The important part is:
|
// generate implicit NoMatch | ||
if (!hasDefault) { | ||
auto &nextState = state.clone(); | ||
nextState.replaceTopBody(Continuation::Exception::NoMatch); | ||
result->emplace_back(missCondition, state, nextState); | ||
} |
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.
// generate implicit NoMatch | |
if (!hasDefault) { | |
auto &nextState = state.clone(); | |
nextState.replaceTopBody(Continuation::Exception::NoMatch); | |
result->emplace_back(missCondition, state, nextState); | |
} | |
// Generate implicit NoMatch. | |
if (!hasDefault) { | |
auto &nextState = state.clone(); | |
nextState.replaceTopBody(Continuation::Exception::NoMatch); | |
result->emplace_back(missCondition, state, nextState); | |
} |
Can you add a trace event for NoMatch? I would use Generic for that. Unfortunately, we do not have access to the parser state label here. |
@fruffy, I've added trace and refactored the code a bit to use Does it makes sense to have this virtual though -- I thought the errors are already parametrizable by the exception handlers and there would be no reason to parametrize them this way. |
I forgot to include the test fragment:
|
This might be an artifact from the early days of the implementation. I do not recall any particular use of overriding |
This one could be checked automatically with #4304. |
Previously, the testgen would generate
NoMatch
exception in parser only if it was caused by explicitly set value, but not when it was an implicit option based on symbolic input. This is now fixed. If there is no default a new successor (guarded by compositemissCondition
) will be added to the select expression.I've opted to implementing this explicitly in the stepper as opposed to adding the
HandleNoMatch
midend pass as the latter would explicitly set theerror
instead of raising the exception. Note that for header stack overflow, testgen already uses a midend pass that sets the error usingverify
and this might be wrong.@fruffy, I'm not sure if I need to change anything else (e.g.
P4ProgramDCGCreator::preorder(const IR::SelectExpression *selectExpression)
. Also, I don't know how to test this automatically, is there a way for testgen test to check that coverage is 1?