We present P4Testgen, a test oracle for the P4-16 language that supports automatic test generation for any P4 target. Unlike prior tools, which were tailored to specific programs and targets, P4Testgen is designed to be general and extensible. It models the complete semantics of the entire packet-processing pipeline including the P4 language, architectures and externs, and target-specific extensions. Handling aspects of packet processing that lie outside of the official language specification is critical for supporting real-world targets. P4Testgen uses taint tracking and concolic execution to handle non-deterministic behaviors and complex externs (e.g., checksums and hash functions) and it provides path selection strategies that reduce the number of tests required to achieve full coverage. We have instantiated P4Testgen for the V1model, eBPF, and Tofino architectures. Each extension required effort commensurate with the complexity of the target. We validated the tests generated by P4Testgen by running them across the entire P4C test suite as well as the programs supplied with the Tofino P4 Studio. Using the tool, we have confirmed 28 bugs in the mature, production toolchains for BMv2 and Tofino.
翻译:我们提出P4Testgen,一个针对P4-16语言的测试预言,支持为任意P4目标自动生成测试。与以往针对特定程序和目标定制的工具不同,P4Testgen被设计为通用且可扩展。它建模了整个数据包处理管线的完整语义,包括P4语言、架构和外部模块,以及目标特定的扩展。处理位于官方语言规范之外的包处理方面,对于支持真实世界目标至关重要。P4Testgen利用污点追踪和混成执行来处理非确定性行为和复杂外部模块(例如校验和与哈希函数),并提供路径选择策略,以减少实现完全覆盖所需的测试数量。我们已为V1model、eBPF和Tofino架构实例化了P4Testgen。每个扩展所需的投入与目标的复杂度相当。我们通过在完整的P4C测试套件以及Tofino P4 Studio附带的程序上运行P4Testgen生成的测试,对其进行了验证。使用该工具,我们在成熟的BMv2和Tofino生产工具链中确认了28个缺陷。