mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-01-21 16:41:36 +01:00
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 <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
b3b8238e6c
commit
35fc29a8d3
Binary file not shown.
BIN
ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap
Normal file
BIN
ryu/tests/packet_data/bgp4/bgp4-keepalive.pcap
Normal file
Binary file not shown.
Binary file not shown.
BIN
ryu/tests/packet_data/bgp4/bgp4-open.pcap
Normal file
BIN
ryu/tests/packet_data/bgp4/bgp4-open.pcap
Normal file
Binary file not shown.
Binary file not shown.
BIN
ryu/tests/packet_data/bgp4/bgp4-update.pcap
Normal file
BIN
ryu/tests/packet_data/bgp4/bgp4-update.pcap
Normal file
Binary file not shown.
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user