-
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
Migrate STF scripts to the STF parser library. Modernize stale run-bmv2-test.py code. #4040
Conversation
2895d87
to
7d89fb7
Compare
Out of curiosity, is part of the goal an attempt to make STF tests more "time order aware", e.g. to be able to add table entries, send one or more packets in, expect one or more packets out, and then add more table entries later that will not be added until after the previous round of packet-in & packet-out checking? Because my understanding is that current STF tests always do the following:
That seems fine to me to limit the functionality of STF tests to that order of operations, personally. If you want something fancier, we have PTF tests for fancier control of the order of events. |
The motivation is actually simpler than that. The ad-hoc implementation is harder to extend and does not support all types of instructions. It is also very specialized to BMv2. The STF grammer implementation on the other hand can be made more general to support different targets. Having the grammar explicit also makes it easier to implement some missing control-plane commands and match types. I am also learning to deal with lex/yacc. :) This PR gets rid of the ad-hoc implementation and replaces it with the parser implementation. |
But the STF test limitations will remain. |
Yes, this is not intended to solve the timing problem. Although once you have the parsed instructions, this should also be implementable. STF is just easier to bootstrap compared to PTF, in particular when implementing a new target. |
I thought the main limitation with the stf parser library is that it did not support expanding environment variable references in the stf script? The bmv2 implementation is also somewhat broken in that it does not implement |
The current approach used by |
090286e
to
a0841e5
Compare
a0841e5
to
c1b84d6
Compare
c1b84d6
to
f8232c0
Compare
@@ -3,9 +3,6 @@ add tab1 ethernet.dstAddr:0xa1a2a3a4a5a6 act(port:2) = A | |||
add tab1 ethernet.dstAddr:0xb1b2b3b4b5b6 act(port:3) = B | |||
add tab1 ethernet.dstAddr:0xc1c2c3c4c5c6 act(port:5) = C | |||
|
|||
expect 2 |
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.
These tests were never working correctly, this was caught by the refactor. STF has a limitation in that it does not catch packets that were not expected to be forwarded if no expect
is present.
See also:
p4lang/behavioral-model#1205
@@ -62,12 +62,6 @@ p4tools_add_xfail_reason( | |||
p4tools_add_xfail_reason( | |||
"testgen-p4c-bmv2" | |||
"Exception" | |||
# Running simple_switch_CLI: Exception Unexpected key field & |
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.
These tests all pass now because we parse key and action names correctly.
@@ -195,6 +196,12 @@ def t_ID(self, t): | |||
# print t, "pos:", t.lexpos, "col:", self.lexer.colno | |||
return t | |||
|
|||
@TOKEN(quoted_identifier) | |||
def t_quoted_ID(self, t): |
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.
Is there a better way to lex an identifier within quotes? The idea here is that any character can be used.
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.
LGTM
I am not sure why, but I see "Merging is blocked" for this PR, even though I have approved it. Perhaps p4lang/p4c rules have been configured so that 2 approving reviews are required? |
This PR is in preparation to fix several open issues with the BMv2 STF testing framework. The first step is to use a proper parser.
run-bmv2-test.py
and use common utilities available in the compiler.Fixes #1489. Fixes #3514.