Skip to content

Commit

Permalink
Update test programs that had errors in their name annotations
Browse files Browse the repository at this point in the history
and for some others, update the error messages we expect to see.

Signed-off-by: Andy Fingerhut <[email protected]>
  • Loading branch information
jafingerhut committed Oct 9, 2024
1 parent bfa62ff commit b062eaa
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 10 deletions.
2 changes: 0 additions & 2 deletions backends/p4test/run-p4-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
152 changes: 152 additions & 0 deletions testdata/p4_16_errors/multicast-bmv2.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#include <core.p4>
#include <v1model.p4>

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;
Original file line number Diff line number Diff line change
@@ -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 {
^^
6 changes: 6 additions & 0 deletions testdata/p4_16_errors_outputs/multicast-bmv2.p4-stderr
Original file line number Diff line number Diff line change
@@ -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() {
^^^^^
4 changes: 2 additions & 2 deletions testdata/p4_16_samples/multicast-bmv2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_16_samples/named_meter_1-bmv2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_16_samples/named_meter_bmv2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b062eaa

Please sign in to comment.