testutils: add new functions to check for dataplane packets
`receive_pkt_check` and `receive_pkt_verify` had slightly different
functionality and neither were sufficient for complex tests. This change
deprecates them and adds new functions.
The high level `verify_packets` function is sufficient for most tests. When
more complex logic is needed the primitive functions `verify_packet`,
`verify_no_packet`, and `verify_no_other_packets` should be used directly.
All OpenFlow 1.0/1.3 tests are updated to use the new functions. The old
functions are left around for compatibility with out of tree tests.
diff --git a/tests/nicira_dec_ttl.py b/tests/nicira_dec_ttl.py
index 39b7f21..66e5757 100644
--- a/tests/nicira_dec_ttl.py
+++ b/tests/nicira_dec_ttl.py
@@ -36,9 +36,10 @@
ofp.action.output(port=portC)])
self.controller.message_send(msg)
- receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=2), [portA], [], self)
- receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=1), [portB], [], self)
- receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=0), [], [portC], self)
+ verify_packet(self, simple_tcp_packet(ip_ttl=2), portA)
+ verify_packet(self, simple_tcp_packet(ip_ttl=1), portB)
+ verify_no_packet(self, simple_tcp_packet(ip_ttl=0), portC)
+ verify_no_other_packets(self)
@nonstandard
class TtlDecrementZeroTtl(base_tests.SimpleDataPlane):
@@ -59,5 +60,6 @@
ofp.action.output(port=portB)])
self.controller.message_send(msg)
- receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=0), [portA], [], self)
- receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=0), [], [portB], self)
+ verify_packet(self, simple_tcp_packet(ip_ttl=0), portA)
+ verify_no_packet(self, simple_tcp_packet(ip_ttl=0), portB)
+ verify_no_other_packets(self)