From b062eaaac36b86214ccc2ba920e93a1cb1c1a197 Mon Sep 17 00:00:00 2001 From: Andy Fingerhut Date: Tue, 8 Oct 2024 17:18:25 -0700 Subject: [PATCH] Update test programs that had errors in their name annotations and for some others, update the error messages we expect to see. Signed-off-by: Andy Fingerhut --- backends/p4test/run-p4-sample.py | 2 - testdata/p4_16_errors/multicast-bmv2.p4 | 152 ++++++++++++++++++ .../issue1803_same_table_name.p4-stderr | 8 +- .../multicast-bmv2.p4-stderr | 6 + testdata/p4_16_samples/multicast-bmv2.p4 | 4 +- testdata/p4_16_samples/named_meter_1-bmv2.p4 | 4 +- testdata/p4_16_samples/named_meter_bmv2.p4 | 4 +- 7 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 testdata/p4_16_errors/multicast-bmv2.p4 create mode 100644 testdata/p4_16_errors_outputs/multicast-bmv2.p4-stderr diff --git a/backends/p4test/run-p4-sample.py b/backends/p4test/run-p4-sample.py index 5ab0fa373c6..554583cca90 100755 --- a/backends/p4test/run-p4-sample.py +++ b/backends/p4test/run-p4-sample.py @@ -362,9 +362,7 @@ def getArch(path): if result == SUCCESS: result = check_generated_files(options, tmpdir, expected_dirname) if (result == SUCCESS) and (not expected_error): - print("jaf dbg just before recompile_file") result = recompile_file(options, ppfile, False, origFileP414) - print("jaf dbg just after recompile_file") if ( (result == SUCCESS) and (not expected_error) diff --git a/testdata/p4_16_errors/multicast-bmv2.p4 b/testdata/p4_16_errors/multicast-bmv2.p4 new file mode 100644 index 00000000000..808fefc0c3d --- /dev/null +++ b/testdata/p4_16_errors/multicast-bmv2.p4 @@ -0,0 +1,152 @@ +#include +#include + +struct routing_metadata_t { + bit<32> nhop_ipv4; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + @name("routing_metadata") + routing_metadata_t routing_metadata; +} + +struct headers { + @name("ethernet") + ethernet_t ethernet; + @name("ipv4") + ipv4_t ipv4; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("parse_ethernet") state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + @name("parse_ipv4") state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + @name("start") state start { + transition parse_ethernet; + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name(".rewrite_mac") action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("._drop") action _drop() { + mark_to_drop(standard_metadata); + } + @name("send_frame") table send_frame { + actions = { + rewrite_mac; + _drop; + } + key = { + standard_metadata.egress_port: exact; + } + size = 256; + } + apply { + send_frame.apply(); + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name(".bcast") action bcast() { + standard_metadata.mcast_grp = 1; + } + @name(".set_dmac") action set_dmac(bit<48> dmac) { + hdr.ethernet.dstAddr = dmac; + } + @name("._drop") action _drop() { + mark_to_drop(standard_metadata); + } + @name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { + meta.routing_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name(".set_nhop_redirect") action set_nhop_redirect(bit<32> nhop_ipv4, bit<9> port) { + meta.routing_metadata.nhop_ipv4 = nhop_ipv4; + standard_metadata.egress_spec = port; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("broadcast") table broadcast { + actions = { + bcast; + } + size = 1; + } + @name("forward") table forward { + actions = { + set_dmac; + _drop; + } + key = { + meta.routing_metadata.nhop_ipv4: exact; + } + size = 512; + } + @name("ipv4_lpm") table ipv4_lpm { + actions = { + set_nhop; + _drop; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + size = 1024; + } + apply { + if (hdr.ipv4.isValid()) { + ipv4_lpm.apply(); + forward.apply(); + } + else { + broadcast.apply(); + } + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_errors_outputs/issue1803_same_table_name.p4-stderr b/testdata/p4_16_errors_outputs/issue1803_same_table_name.p4-stderr index d6929e2b197..1128bce3b15 100644 --- a/testdata/p4_16_errors_outputs/issue1803_same_table_name.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue1803_same_table_name.p4-stderr @@ -1,2 +1,6 @@ -[--Werror=duplicate] error: Name 't0' is used for multiple table objects in the P4Info message -[--Werror=duplicate] error: Found 1 duplicate name(s) in the P4Info +issue1803_same_table_name.p4(19): [--Werror=duplicate] error: .t0: conflicting control plane name: .t0 + table t0 { + ^^ +issue1803_same_table_name.p4(19) + table t0 { + ^^ diff --git a/testdata/p4_16_errors_outputs/multicast-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/multicast-bmv2.p4-stderr new file mode 100644 index 00000000000..835e09d908e --- /dev/null +++ b/testdata/p4_16_errors_outputs/multicast-bmv2.p4-stderr @@ -0,0 +1,6 @@ +multicast-bmv2.p4(87): [--Werror=duplicate] error: ._drop: conflicting control plane name: ._drop + @name("._drop") action _drop() { + ^^^^^ +multicast-bmv2.p4(62) + @name("._drop") action _drop() { + ^^^^^ diff --git a/testdata/p4_16_samples/multicast-bmv2.p4 b/testdata/p4_16_samples/multicast-bmv2.p4 index 808fefc0c3d..b912801932a 100644 --- a/testdata/p4_16_samples/multicast-bmv2.p4 +++ b/testdata/p4_16_samples/multicast-bmv2.p4 @@ -59,7 +59,7 @@ control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t @name(".rewrite_mac") action rewrite_mac(bit<48> smac) { hdr.ethernet.srcAddr = smac; } - @name("._drop") action _drop() { + @name("_drop") action _drop() { mark_to_drop(standard_metadata); } @name("send_frame") table send_frame { @@ -84,7 +84,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ @name(".set_dmac") action set_dmac(bit<48> dmac) { hdr.ethernet.dstAddr = dmac; } - @name("._drop") action _drop() { + @name("_drop") action _drop() { mark_to_drop(standard_metadata); } @name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { diff --git a/testdata/p4_16_samples/named_meter_1-bmv2.p4 b/testdata/p4_16_samples/named_meter_1-bmv2.p4 index 80c156d848e..1e2f85fe56f 100644 --- a/testdata/p4_16_samples/named_meter_1-bmv2.p4 +++ b/testdata/p4_16_samples/named_meter_1-bmv2.p4 @@ -76,11 +76,11 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_action") action m_action_0(bit<9> meter_idx) { + @name("m_action_2") action m_action_0(bit<9> meter_idx) { standard_metadata.egress_spec = meter_idx; my_meter.read(meta.meta.meter_tag); } - @name("_nop") action _nop_0() { + @name("_nop_2") action _nop_0() { my_meter.read(meta.meta.meter_tag); } @name("m_table") table m_table { diff --git a/testdata/p4_16_samples/named_meter_bmv2.p4 b/testdata/p4_16_samples/named_meter_bmv2.p4 index f420c6efeeb..1f0ecf84210 100644 --- a/testdata/p4_16_samples/named_meter_bmv2.p4 +++ b/testdata/p4_16_samples/named_meter_bmv2.p4 @@ -75,12 +75,12 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_ size = 16; default_action = NoAction(); } - @name("m_action") action m_action_0(bit<9> meter_idx) { + @name("m_action_2") action m_action_0(bit<9> meter_idx) { standard_metadata.egress_spec = meter_idx; standard_metadata.egress_spec = 9w1; my_meter.read(meta.meta.meter_tag); } - @name("_nop") action _nop_0() { + @name("_nop_2") action _nop_0() { my_meter.read(meta.meta.meter_tag); } @name("m_table") table m_table {