Can you please squash this patch into padding patch? On Fri, May 24, 2013 at 05:08:30PM +0000, Shaun Crampton wrote: > From: Shaun Crampton <[email protected]> > > Unit test updates to take account of ethernet padding on small packets. > > Signed-off-by: Shaun Crampton <[email protected]> > > --- > ryu/tests/unit/packet/test_ethernet.py | 6 ++++-- > ryu/tests/unit/packet/test_lldp.py | 3 ++- > ryu/tests/unit/packet/test_packet.py | 37 > +++++++++++++++++++------------- > 3 files changed, 28 insertions(+), 18 deletions(-) > > diff --git a/ryu/tests/unit/packet/test_ethernet.py > b/ryu/tests/unit/packet/test_ethernet.py > index 6378bb6..b0362b9 100644 > --- a/ryu/tests/unit/packet/test_ethernet.py > +++ b/ryu/tests/unit/packet/test_ethernet.py > @@ -75,15 +75,17 @@ class Test_ethernet(unittest.TestCase): > def test_serialize(self): > data = bytearray() > prev = None > - buf = self.e.serialize(data, prev) > + header, suffix = self.e.serialize(data, prev) > > fmt = ethernet._PACK_STR > - res = struct.unpack(fmt, buf) > + res = struct.unpack(fmt, header) > > eq_(res[0], self.dst) > eq_(res[1], self.src) > eq_(res[2], self.ethertype) > > + eq_(len(header) + len(suffix), 60) > + > @raises(Exception) > def test_malformed_ethernet(self): > m_short_buf = self.buf[1:ethernet._MIN_LEN] > diff --git a/ryu/tests/unit/packet/test_lldp.py > b/ryu/tests/unit/packet/test_lldp.py > index 23402f8..8d69ca3 100644 > --- a/ryu/tests/unit/packet/test_lldp.py > +++ b/ryu/tests/unit/packet/test_lldp.py > @@ -116,7 +116,8 @@ class TestLLDPMandatoryTLV(unittest.TestCase): > eq_(len(pkt.protocols), 2) > > pkt.serialize() > - eq_(pkt.data, self.data) > + eq_(pkt.data[:len(self.data)], self.data) > + eq_(len(pkt.data), 60) > > > class TestLLDPOptionalTLV(unittest.TestCase): > diff --git a/ryu/tests/unit/packet/test_packet.py > b/ryu/tests/unit/packet/test_packet.py > index 2e2601a..28cf3c7 100644 > --- a/ryu/tests/unit/packet/test_packet.py > +++ b/ryu/tests/unit/packet/test_packet.py > @@ -89,6 +89,7 @@ class TestPacket(unittest.TestCase): > + self.dst_ip_bin > > buf = e_buf + a_buf > + buf += '\0' * (60 - len(buf)) > eq_(buf, p.data) > > # parse > @@ -149,7 +150,11 @@ class TestPacket(unittest.TestCase): > + self.dst_mac \ > + self.dst_ip_bin > > - buf = e_buf + v_buf + a_buf > + # ethernet padding > + e_pad = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > + > + buf = e_buf + v_buf + a_buf + e_pad > + > eq_(buf, p.data) > > # parse > @@ -185,7 +190,7 @@ class TestPacket(unittest.TestCase): > eq_(self.dst_ip, p_arp.dst_ip) > > def test_ipv4_udp(self): > - # buid packet > + # build packet > e = ethernet.ethernet(self.dst_mac, self.src_mac, > ether.ETH_TYPE_IP) > ip = ipv4.ipv4(4, 5, 1, 0, 3, 1, 4, 64, inet.IPPROTO_UDP, 0, > @@ -205,26 +210,28 @@ class TestPacket(unittest.TestCase): > + '\x08\x00' > > # ipv4 !BBHHHBBHII > - ip_buf = '\x45' \ > - + '\x01' \ > - + '\x00\x3C' \ > - + '\x00\x03' \ > - + '\x20\x04' \ > - + '\x40' \ > - + '\x11' \ > - + '\x00\x00' \ > - + self.src_ip_bin \ > - + self.dst_ip_bin > + ip_buf = ('\x45' + # Version > + '\x01' + # DSCP/ECN > + '\x00\x3C' + # Total length 0x3c = 60 > + '\x00\x03' + # Identification > + '\x20\x04' + # Flags/fragment offset > + '\x40' + # TTL > + '\x11' + # Protocol > + '\xdf9' + # Checksum > + self.src_ip_bin + > + self.dst_ip_bin) > > # udp !HHHH > u_buf = '\x19\x0F' \ > + '\x1F\x90' \ > + '\x00\x28' \ > - + '\x00\x00' > + + 'w\xb2' > > buf = e_buf + ip_buf + u_buf + self.payload > + eq_(len(ip_buf) + len(u_buf) + len(self.payload), 0x3c) > + eq_(bytearray(buf), p.data) > > - # parse > + # parse the serialized packet > pkt = packet.Packet(array.array('B', p.data)) > protocols = self.get_protocols(pkt) > p_eth = protocols['ethernet'] > @@ -268,7 +275,7 @@ class TestPacket(unittest.TestCase): > eq_(packet_utils.checksum(t), 0) > > # payload > - ok_('payload' in protocols) > + ok_('payload' in protocols, msg="Payload missing %s" % protocols) > eq_(self.payload, protocols['payload'].tostring()) > > def test_ipv4_tcp(self): > -- > 1.7.9.5 > > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may > _______________________________________________ > Ryu-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ryu-devel >
-- yamahata ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
