p4lang / p4c

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

First take at p4tc automated tests #5011

Open vbnogueira opened 1 week ago

vbnogueira commented 1 week ago

First take at implementing the automated testing code for tc backend. In a nutshell, what it's doing is expanding on the already existing run-tc-test.py script. The expansion consists of:

Compiling the generated C files to eBPF bytecode Extracting a P4TC kernel image from github Compiling P4TC's version of iproute2 Spawning a VM using virtme to boot the P4TC kernel Executing the template script generated by the compiler Loading the generated eBPF parser and control blocks binaries using a TC P4 filter Loading the runtime rules specified in the samples directory (*.rules) Parsing an STF in the samples directory detailing what packets to send/expect Sending the packets using scapy Verifying that the sent packets (and eventual received packets from the p4tc pipeline) and correct according to the STF file Opening it as a draft PR because we still need to see how this works with github actions Locally it's doing fine, however we never know

I created a separate directory for the tests that involve STFs testdata/p4tc_samples_stf/ to make it cleaner However that might've been overkill, I can undo that if reviewers think it's best

fruffy commented 1 week ago

The installation might be missing gcc-multilib.

I recommend adding a TC-specific section here: https://github.com/p4lang/p4c/blob/main/tools/ci-build.sh#L170

vbnogueira commented 1 week ago

The installation might be missing gcc-multilib.

I recommend adding a TC-specific section here: https://github.com/p4lang/p4c/blob/main/tools/ci-build.sh#L170

Thank you, will do