We present P4Testgen, a test oracle for the P4-16 language that supports automatic generation of packet tests for any P4-programmable device. Given a P4 program and sufficient time, P4Testgen generates tests that cover every reachable statement in the input program. Each generated test consists of an input packet, control-plane configuration, and output packet(s), and can be executed in software or on hardware. Unlike prior work, P4Testgen is open source and extensible, making it a general resource for the community. P4Testgen not only covers the full P4-16 language specification, it also supports modeling the semantics of an entire packet-processing pipeline, including target-specific behaviors-i.e., whole-program semantics. Handling aspects of packet processing that lie outside of the official specification is critical for supporting real-world targets (e.g., switches, NICs, end host stacks). In addition, P4Testgen uses taint tracking and concolic execution to model complex externs (e.g., checksums and hash functions) that have been omitted by other tools, and ensures the generated tests are correct and deterministic. We have instantiated P4Testgen to build test oracles for the V1model, eBPF, and the Tofino (TNA and T2NA) architectures; each of these extensions only required effort commensurate with the complexity of the target. We validated the tests generated by P4Testgen by running them across the entire P4C program test suite as well as the Tofino programs supplied with Intel's P4 Studio. In just a few months using the tool, we discovered and confirmed 25 bugs in the mature, production toolchains for BMv2 and Tofino, and are conducting ongoing investigations into further faults uncovered by P4Testgen.
翻译:P4Testergen 是一个用于支持为任何 P4 - 16 可编程设备自动生成包件测试的测试器。 P4Testergen 在一个P4 程序和足够时间的情况下, 生成了包含输入程序中每个可达语句的测试。 每个生成的测试都包含一个输入包、 控制机配置和输出包, 并且可以在软件或硬件中执行。 与先前的工作不同, P4Tementgen 是开放源, 可以扩展, 使它成为社区的一般资源。 P4Tementgen 不仅覆盖全P4 - 16语言规格, 而且还支持整个包件处理管道的匹配测试器, 包括目标特定的行为 - e. e., 完整程序。 处理位于正式规格之外的包处理对于支持真实世界目标( 如开关、 NIC 、 终端主机堆) 至关重要。 此外, P4T4T2 运行系统不仅通过测试程序, 也通过测试程序生成了自动测试程序, 也通过测试程序创建了自动测试程序 。