diff --git a/p4_symbolic/ir/BUILD.bazel b/p4_symbolic/ir/BUILD.bazel index 8ae8aa81..ca493ddd 100644 --- a/p4_symbolic/ir/BUILD.bazel +++ b/p4_symbolic/ir/BUILD.bazel @@ -243,3 +243,10 @@ ir_parsing_test( p4_deps = ["//p4_symbolic/testdata:common/headers.p4"], p4_program = "//p4_symbolic/testdata:parser/hex_string_transition.p4", ) + +ir_parsing_test( + name = "fall_through_transition_test", + golden_file = "expected/fall_through_transition.txt", + p4_deps = ["//p4_symbolic/testdata:common/headers.p4"], + p4_program = "//p4_symbolic/testdata:parser/fall_through_transition.p4", +) diff --git a/p4_symbolic/ir/expected/fall_through_transition.txt b/p4_symbolic/ir/expected/fall_through_transition.txt index 1240f4cf..08808a10 100644 --- a/p4_symbolic/ir/expected/fall_through_transition.txt +++ b/p4_symbolic/ir/expected/fall_through_transition.txt @@ -394,11 +394,4 @@ errors { value: 3 } } -deparsers { - key: "deparser" - value { - name: "deparser" - header_order: "ethernet" - } -} diff --git a/p4_symbolic/testdata/parser/fall_through_transition.p4 b/p4_symbolic/testdata/parser/fall_through_transition.p4 new file mode 100644 index 00000000..e6f79f92 --- /dev/null +++ b/p4_symbolic/testdata/parser/fall_through_transition.p4 @@ -0,0 +1,68 @@ +#include +#include "../common/headers.p4" + +struct local_metadata_t { + /* empty */ +} + +struct headers_t { + ethernet_t ethernet; + ipv4_t ipv4; +} + +parser packet_parser(packet_in packet, out headers_t headers, + inout local_metadata_t local_metadata, + inout standard_metadata_t standard_metadata) { + state start { + transition parse_ethernet; + } + + state parse_ethernet { + packet.extract(headers.ethernet); + transition select(headers.ethernet.ether_type) { + ETHERTYPE_IPV4: parse_ipv4; + } + } + + state parse_ipv4 { + packet.extract(headers.ipv4); + transition accept; + } +} + +control empty_verify_checksum(inout headers_t headers, + inout local_metadata_t local_metadata) { + apply {} +} // control empty_verify_checksum + +control ingress(inout headers_t headers, + inout local_metadata_t local_metadata, + inout standard_metadata_t standard_metadata) { + apply {} +} // control ingress + +control egress(inout headers_t headers, + inout local_metadata_t local_metadata, + inout standard_metadata_t standard_metadata) { + apply {} +} // control egress + +control empty_compute_checksum(inout headers_t headers, + inout local_metadata_t local_metadata) { + apply {} +} // control empty_compute_checksum + +control packet_deparser(packet_out packet, in headers_t headers) { + apply { + packet.emit(headers.ethernet); + } +} // control packet_deparser + +V1Switch( + packet_parser(), + empty_verify_checksum(), + ingress(), + egress(), + empty_compute_checksum(), + packet_deparser() +) main;