diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-11-07 16:04:21 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-11-14 12:14:38 +0900 |
commit | 7e1f64865d43a9668973e369fdbd8790e83e9057 (patch) | |
tree | 2f2e32d8799ef814ed9cb8705f559cc2d88e9ed9 | |
parent | 73f6105e8899146e3b20731fa87b18b5404668e5 (diff) |
test_bgp: Enable to check parsed BGP message
This patch fixes to check if the parsed protocols list contains
the BGP message as expected.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/unit/packet/test_bgp.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ryu/tests/unit/packet/test_bgp.py b/ryu/tests/unit/packet/test_bgp.py index 2ab213c0..a3c922f8 100644 --- a/ryu/tests/unit/packet/test_bgp.py +++ b/ryu/tests/unit/packet/test_bgp.py @@ -24,6 +24,7 @@ import unittest from nose.tools import eq_ from nose.tools import ok_ +from ryu.utils import binary_str from ryu.lib import pcaplib from ryu.lib.packet import packet from ryu.lib.packet import bgp @@ -263,10 +264,15 @@ class Test_bgp(unittest.TestCase): LOG.debug('*** testing %s ...', f) for _, buf in pcaplib.Reader( open(BGP4_PACKET_DATA_DIR + f + '.pcap', 'rb')): + # Checks if BGP message can be parsed as expected. pkt = packet.Packet(buf) - LOG.debug(pkt) + ok_(isinstance(pkt.protocols[-1], bgp.BGPMessage), + 'Failed to parse BGP message: %s' % pkt) + + # Checks if BGP message can be serialized as expected. pkt.serialize() - eq_(buf, pkt.data) + eq_(buf, pkt.data, + "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data))) def test_json1(self): opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200, |