p4lang / p4c

P4_16 reference compiler
https://p4.org/
Apache License 2.0
669 stars 441 forks source link

Do testgen tests using STF files compile the P4 program once per test case? #4571

Open jafingerhut opened 6 months ago

jafingerhut commented 6 months ago

I have run a test like this manually after building p4c:

cd p4c/build
./testgen/testgen-p4c-bmv2-stf/fabric.p4.test -v

From the output it appears to behave as follows:

Thus it seems to compile the P4 program 10 times.

It seems like it should be straightforward to run such a test in a way that it compiles the P4 program only once, true?

fruffy commented 6 months ago

Yes, this is a limitation of the Python STF runner, not P4Testgen. P4Testgen only requires that state is being reset between tests.

I see two ways to fix this.

  1. Change P4Testgen to consolidate all tests into a single STF file and make it reset switch state between each single tests. This will require adding a reset command to STF, similar to how PTF works.

  2. Just add an option to the run-bmv2-test.py to take multiple tests as input. Only compile once but reinstantiate the switch between each test.