Merge branch 'master' of github.com:/floodlight/oftest
diff --git a/src/python/oftest/dataplane.py b/src/python/oftest/dataplane.py
index 7ce2738..252726a 100644
--- a/src/python/oftest/dataplane.py
+++ b/src/python/oftest/dataplane.py
@@ -31,6 +31,19 @@
ETH_P_ALL = 0x03
RCV_TIMEOUT = 10000
+def match_exp_pkt(exp_pkt, pkt):
+ """
+ Compare the string value of pkt with the string value of exp_pkt,
+ and return True iff they are identical. If the length of exp_pkt is
+ less than the minimum Ethernet frame size (60 bytes), then padding
+ bytes in pkt are ignored.
+ """
+ e = str(exp_pkt)
+ p = str(pkt)
+ if len(e) < 60:
+ p = p[:len(e)]
+ return e == p
+
class DataPlanePort(Thread):
"""
Class defining a port monitoring object.
@@ -140,7 +153,7 @@
if (not self.parent.want_pkt_port or
self.parent.want_pkt_port == self.port_number):
if self.parent.exp_pkt:
- if str(self.parent.exp_pkt) != str(rcvmsg):
+ if not match_exp_pkt(self.parent.exp_pkt, rcvmsg):
drop_pkt = True
if not drop_pkt:
self.parent.got_pkt_port = self.port_number
@@ -331,7 +344,7 @@
pkt, time = self.port_list[port_number].dequeue(use_lock=False)
if not exp_pkt:
break
- if str(pkt) == str(exp_pkt):
+ if match_exp_pkt(exp_pkt, pkt):
break
pkt = None # Discard silently
if pkt:
diff --git a/tests/basic.py b/tests/basic.py
index 7bb3bbf..9f43fcd 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -252,7 +252,7 @@
(response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN, 2)
if not response: # Timeout
break
- if str(pkt) == response.data[:len(str(pkt))]: # Got match
+ if dataplane.match_exp_pkt(pkt, response.data): # Got match
break
if not basic_config["relax"]: # Only one attempt to match
break
@@ -263,7 +263,7 @@
self.assertTrue(response is not None,
'Packet in message not received on port ' +
str(of_port))
- if str(pkt) != response.data[:len(str(pkt))]:
+ if not dataplane.match_exp_pkt(pkt, response.data):
basic_logger.debug("Sent %s" % format_packet(pkt))
basic_logger.debug("Resp %s" % format_packet(response.data))
self.assertTrue(False,
@@ -318,7 +318,7 @@
basic_logger.info("PacketOut: got pkt from " + str(of_port))
if of_port is not None:
self.assertEqual(of_port, dp_port, "Unexpected receive port")
- if str(outpkt) != str(pkt)[:len(str(outpkt))]:
+ if not dataplane.match_exp_pkt(outpkt, pkt):
basic_logger.debug("Sent %s" % format_packet(outpkt))
basic_logger.debug("Resp %s" % format_packet(
str(pkt)[:len(str(outpkt))]))
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index e5976c3..38560bc 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -49,6 +49,8 @@
@param config The configuration dictionary; see oft
"""
+ basic.test_set_init(config)
+
global fs_port_map
global fs_logger
global fs_config
diff --git a/tests/pktact.py b/tests/pktact.py
index b79c633..ee60e96 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -80,6 +80,8 @@
@param config The configuration dictionary; see oft
"""
+ basic.test_set_init(config)
+
global pa_port_map
global pa_logger
global pa_config