From 35fc29a8d326446dfb6950d98d866fe2783ba96c Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Wed, 25 May 2016 15:27:38 +0900 Subject: test_bgp: Enable to test parser with pcap file Currently, test_bgp uses packet_data/bgp4/* files which contain only BGP protocol binary data. This patch convert packet_data file into pcap file and enable to test BGP packet library with pcap file. With pcap file, we can easily check packet data validity by using Wireshark or other packet sniffer tools. Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/tests/packet_data/bgp4/bgp4-keepalive | Bin 19 -> 0 bytes ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap | Bin 0 -> 113 bytes ryu/tests/packet_data/bgp4/bgp4-open | Bin 53 -> 0 bytes ryu/tests/packet_data/bgp4/bgp4-open.pcap | Bin 0 -> 147 bytes ryu/tests/packet_data/bgp4/bgp4-update | Bin 52 -> 0 bytes ryu/tests/packet_data/bgp4/bgp4-update.pcap | Bin 0 -> 146 bytes ryu/tests/unit/packet/test_bgp.py | 10 +++++----- 7 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 ryu/tests/packet_data/bgp4/bgp4-keepalive create mode 100644 ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap delete mode 100644 ryu/tests/packet_data/bgp4/bgp4-open create mode 100644 ryu/tests/packet_data/bgp4/bgp4-open.pcap delete mode 100644 ryu/tests/packet_data/bgp4/bgp4-update create mode 100644 ryu/tests/packet_data/bgp4/bgp4-update.pcap diff --git a/ryu/tests/packet_data/bgp4/bgp4-keepalive b/ryu/tests/packet_data/bgp4/bgp4-keepalive deleted file mode 100644 index 78ebde2e..00000000 Binary files a/ryu/tests/packet_data/bgp4/bgp4-keepalive and /dev/null differ diff --git a/ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap b/ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap new file mode 100644 index 00000000..355e9dab Binary files /dev/null and b/ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap differ diff --git a/ryu/tests/packet_data/bgp4/bgp4-open b/ryu/tests/packet_data/bgp4/bgp4-open deleted file mode 100644 index 701f2fbd..00000000 Binary files a/ryu/tests/packet_data/bgp4/bgp4-open and /dev/null differ diff --git a/ryu/tests/packet_data/bgp4/bgp4-open.pcap b/ryu/tests/packet_data/bgp4/bgp4-open.pcap new file mode 100644 index 00000000..1ef507bb Binary files /dev/null and b/ryu/tests/packet_data/bgp4/bgp4-open.pcap differ diff --git a/ryu/tests/packet_data/bgp4/bgp4-update b/ryu/tests/packet_data/bgp4/bgp4-update deleted file mode 100644 index 8fbc238d..00000000 Binary files a/ryu/tests/packet_data/bgp4/bgp4-update and /dev/null differ diff --git a/ryu/tests/packet_data/bgp4/bgp4-update.pcap b/ryu/tests/packet_data/bgp4/bgp4-update.pcap new file mode 100644 index 00000000..37354938 Binary files /dev/null and b/ryu/tests/packet_data/bgp4/bgp4-update.pcap differ diff --git a/ryu/tests/unit/packet/test_bgp.py b/ryu/tests/unit/packet/test_bgp.py index 17bef871..b3c11984 100644 --- a/ryu/tests/unit/packet/test_bgp.py +++ b/ryu/tests/unit/packet/test_bgp.py @@ -22,6 +22,7 @@ import unittest from nose.tools import eq_ from nose.tools import ok_ +from ryu.lib.packet import packet from ryu.lib.packet import bgp from ryu.lib.packet import afi from ryu.lib.packet import safi @@ -208,11 +209,10 @@ class Test_bgp(unittest.TestCase): for f in files: print('testing %s' % f) - binmsg = open(BGP4_PACKET_DATA_DIR + f, 'rb').read() - msg, rest = bgp.BGPMessage.parser(binmsg) - binmsg2 = msg.serialize() - eq_(binmsg, binmsg2) - eq_(rest, b'') + msg_buf = open(BGP4_PACKET_DATA_DIR + f + '.pcap', 'rb').read() + pkt = packet.Packet(msg_buf) + pkt.serialize() + eq_(msg_buf, pkt.data) def test_json1(self): opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200, -- cgit v1.2.3