Skip to content

Commit

Permalink
Add .stf files for more gateway tests (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDodd authored Oct 14, 2016
1 parent d926f55 commit d578cfc
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 103 deletions.
12 changes: 5 additions & 7 deletions testdata/p4_14_samples/gateway5.p4
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ header_type data_t {
fields {
f1 : 32;
f2 : 32;
f3 : 32;
f4 : 32;
x1 : 2;
pad0 : 3;
x2 : 2;
pad1 : 5;
x3 : 1;
pad2 : 2;
pad2 : 3;
skip : 32;
x4 : 1;
x5 : 1;
Expand All @@ -40,14 +38,14 @@ parser start {
}

action noop() { }
action setf4(val) { modify_field(data.f4, val); }
action output(port) { modify_field(standard_metadata.egress_spec, port); }

table test1 {
reads {
data.f1 : exact;
}
actions {
setf4;
output;
noop;
}
}
Expand All @@ -56,13 +54,13 @@ table test2 {
data.f2 : exact;
}
actions {
setf4;
output;
noop;
}
}

control ingress {
if (data.x1 == 1 and data.x4 == 0) {
if (data.x2 == 1 and data.x4 == 0) {
apply(test1);
} else {
apply(test2);
Expand Down
12 changes: 12 additions & 0 deletions testdata/p4_14_samples/gateway5.stf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
add test1 data.f1:0x12345678 output(port:2)
add test2 data.f2:0x12345678 output(port:3)

expect 2 12345678 12345678 0200 00000000 00 f1
packet 0 12345678 12345678 0200 00000000 00 f1
expect 3 12345678 12345678 0200 00000000 80 f2
packet 0 12345678 12345678 0200 00000000 80 f2
expect 3 12345678 12345678 0600 00000000 80 f3
packet 0 12345678 12345678 0600 00000000 80 f3
expect 3 12345678 12345678 0600 00000000 00 f4
packet 0 12345678 12345678 0600 00000000 00 f4

8 changes: 3 additions & 5 deletions testdata/p4_14_samples/gateway6.p4
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ header_type data_t {
fields {
f1 : 32;
f2 : 32;
f3 : 32;
f4 : 32;
b1 : 8;
b2 : 8;
b3 : 8;
Expand All @@ -34,14 +32,14 @@ parser start {
}

action noop() { }
action setb1(val) { modify_field(data.b1, val); }
action output(port) { modify_field(standard_metadata.egress_spec, port); }

table test1 {
reads {
data.f1 : exact;
}
actions {
setb1;
output;
noop;
}
}
Expand All @@ -50,7 +48,7 @@ table test2 {
data.f2 : exact;
}
actions {
setb1;
output;
noop;
}
}
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4_14_samples/gateway6.stf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add test1 data.f1:0x12345678 output(port:2)
add test2 data.f2:0x12345678 output(port:3)

expect 2 12345678 12345678 00 01 00 00 f1
packet 0 12345678 12345678 00 01 00 00 f1
expect 3 12345678 12345678 00 02 00 00 f2
packet 0 12345678 12345678 00 02 00 00 f2
expect 2 12345678 12345678 00 f1 00 00 f3
packet 0 12345678 12345678 00 f1 00 00 f3

8 changes: 3 additions & 5 deletions testdata/p4_14_samples/gateway7.p4
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ header_type data_t {
fields {
f1 : 32;
f2 : 32;
f3 : 32;
f4 : 32;
b1 : 8;
b2 : 8;
b3 : 8;
Expand All @@ -34,14 +32,14 @@ parser start {
}

action noop() { }
action setb1(val) { modify_field(data.b1, val); }
action output(port) { modify_field(standard_metadata.egress_spec, port); }

table test1 {
reads {
data.f1 : exact;
}
actions {
setb1;
output;
noop;
}
}
Expand All @@ -50,7 +48,7 @@ table test2 {
data.f2 : exact;
}
actions {
setb1;
output;
noop;
}
}
Expand Down
13 changes: 13 additions & 0 deletions testdata/p4_14_samples/gateway7.stf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

add test1 data.f1:0x12345678 output(port:2)
add test2 data.f2:0x12345678 output(port:3)

expect 2 12345678 12345678 00 33 00 00 f1
packet 0 12345678 12345678 00 33 00 00 f1
expect 3 12345678 12345678 00 32 00 00 f2
packet 0 12345678 12345678 00 32 00 00 f2
expect 2 12345678 12345678 00 f1 00 00 f3
packet 0 12345678 12345678 00 f1 00 00 f3
expect 3 12345678 12345678 00 03 00 00 f4
packet 0 12345678 12345678 00 03 00 00 f4

14 changes: 6 additions & 8 deletions testdata/p4_14_samples_outputs/gateway5-first.p4
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
header data_t {
bit<32> f1;
bit<32> f2;
bit<32> f3;
bit<32> f4;
bit<2> x1;
bit<3> pad0;
bit<2> x2;
bit<5> pad1;
bit<1> x3;
bit<2> pad2;
bit<3> pad2;
bit<32> skip;
bit<1> x4;
bit<1> x5;
Expand All @@ -34,14 +32,14 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name("setf4") action setf4(bit<32> val) {
hdr.data.f4 = val;
@name("output") action output(bit<9> port) {
standard_metadata.egress_spec = port;
}
@name("noop") action noop() {
}
@name("test1") table test1() {
actions = {
setf4();
output();
noop();
NoAction();
}
Expand All @@ -52,7 +50,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
}
@name("test2") table test2() {
actions = {
setf4();
output();
noop();
NoAction();
}
Expand All @@ -62,7 +60,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
default_action = NoAction();
}
apply {
if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0)
if (hdr.data.x2 == 2w1 && hdr.data.x4 == 1w0)
test1.apply();
else
test2.apply();
Expand Down
14 changes: 6 additions & 8 deletions testdata/p4_14_samples_outputs/gateway5-frontend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
header data_t {
bit<32> f1;
bit<32> f2;
bit<32> f3;
bit<32> f4;
bit<2> x1;
bit<3> pad0;
bit<2> x2;
bit<5> pad1;
bit<1> x3;
bit<2> pad2;
bit<3> pad2;
bit<32> skip;
bit<1> x4;
bit<1> x5;
Expand All @@ -34,14 +32,14 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name("setf4") action setf4_0(bit<32> val) {
hdr.data.f4 = val;
@name("output") action output_0(bit<9> port) {
standard_metadata.egress_spec = port;
}
@name("noop") action noop_0() {
}
@name("test1") table test1_0() {
actions = {
setf4_0();
output_0();
noop_0();
NoAction();
}
Expand All @@ -52,7 +50,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
}
@name("test2") table test2_0() {
actions = {
setf4_0();
output_0();
noop_0();
NoAction();
}
Expand All @@ -62,7 +60,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
default_action = NoAction();
}
apply {
if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0)
if (hdr.data.x2 == 2w1 && hdr.data.x4 == 1w0)
test1_0.apply();
else
test2_0.apply();
Expand Down
18 changes: 8 additions & 10 deletions testdata/p4_14_samples_outputs/gateway5-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
header data_t {
bit<32> f1;
bit<32> f2;
bit<32> f3;
bit<32> f4;
bit<2> x1;
bit<3> pad0;
bit<2> x2;
bit<5> pad1;
bit<1> x3;
bit<2> pad2;
bit<3> pad2;
bit<32> skip;
bit<1> x4;
bit<1> x5;
Expand All @@ -38,19 +36,19 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
}
@name("NoAction_2") action NoAction_0() {
}
@name("setf4") action setf4_0(bit<32> val) {
hdr.data.f4 = val;
@name("output") action output_0(bit<9> port) {
standard_metadata.egress_spec = port;
}
@name("setf4") action setf4_2(bit<32> val) {
hdr.data.f4 = val;
@name("output") action output_2(bit<9> port) {
standard_metadata.egress_spec = port;
}
@name("noop") action noop_0() {
}
@name("noop") action noop_2() {
}
@name("test1") table test1() {
actions = {
setf4_0();
output_0();
noop_0();
NoAction();
}
Expand All @@ -61,7 +59,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
}
@name("test2") table test2() {
actions = {
setf4_2();
output_2();
noop_2();
NoAction_0();
}
Expand All @@ -71,7 +69,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
default_action = NoAction_0();
}
apply {
if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0)
if (hdr.data.x2 == 2w1 && hdr.data.x4 == 1w0)
test1.apply();
else
test2.apply();
Expand Down
14 changes: 6 additions & 8 deletions testdata/p4_14_samples_outputs/gateway5.p4
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
header data_t {
bit<32> f1;
bit<32> f2;
bit<32> f3;
bit<32> f4;
bit<2> x1;
bit<3> pad0;
bit<2> x2;
bit<5> pad1;
bit<1> x3;
bit<2> pad2;
bit<3> pad2;
bit<32> skip;
bit<1> x4;
bit<1> x5;
Expand All @@ -34,14 +32,14 @@ parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name("setf4") action setf4(bit<32> val) {
hdr.data.f4 = val;
@name("output") action output(bit<9> port) {
standard_metadata.egress_spec = port;
}
@name("noop") action noop() {
}
@name("test1") table test1() {
actions = {
setf4;
output;
noop;
NoAction;
}
Expand All @@ -52,7 +50,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
}
@name("test2") table test2() {
actions = {
setf4;
output;
noop;
NoAction;
}
Expand All @@ -62,7 +60,7 @@ control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_
default_action = NoAction();
}
apply {
if (hdr.data.x1 == 2w1 && hdr.data.x4 == 1w0) {
if (hdr.data.x2 == 2w1 && hdr.data.x4 == 1w0) {
test1.apply();
}
else {
Expand Down
Loading

0 comments on commit d578cfc

Please sign in to comment.