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 <[email protected]>
---
 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 
78ebde2e66d5283d5601ba30a9cd3ebb3f054081..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 19
OcmezW9~CeNvj70Mg%Ah;

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 
0000000000000000000000000000000000000000..355e9dab3e45179f0b29f6629099a7f7a53a5b23
GIT binary patch
literal 113
zcmca|c+)~A1{MYw`2U}Qff2~Lc;7j^RF#jx6UYW(K_z3C(6m*%&)j|YpM$}bfx#N2
j<3HQ-U0e(dOhC+dgqdM8NDKr5fcP>iP#z612(thHe3vAG

literal 0
HcmV?d00001

diff --git a/ryu/tests/packet_data/bgp4/bgp4-open 
b/ryu/tests/packet_data/bgp4/bgp4-open
deleted file mode 100644
index 
701f2fbdac3d761bd13845afa17ac3bfcd7c0fe1..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 53
wcmezW9~Cf|GP3;t$FOCMV1TIv6B{E710w??6H@~N6B82y6PqIo1H=D+0A_j@82|tP

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 
0000000000000000000000000000000000000000..1ef507bb1628a2b0568e54bc029c13ec670eefa7
GIT binary patch
literal 147
zcmca|c+)~A1{MYw`2U}Qff2|le&8H_`3^5bHjoX%f=b3Np=qmjpSk<)KL>*=14ArG
z$A7lvGq@NSn1Gn^2s6WGkQfLA0P(W#KzTI4V9Lny{~yDaHG%=A5=?B2EI_*$nV1?F
Qn3$LtnAjYF?)d)?0D#jiQvd(}

literal 0
HcmV?d00001

diff --git a/ryu/tests/packet_data/bgp4/bgp4-update 
b/ryu/tests/packet_data/bgp4/bgp4-update
deleted file mode 100644
index 
8fbc238ddd61c9b386bbde33f8be9fd430e356be..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 52
tcmezW9~Cf|FflMNNIEbwG6XO&a4`XS|NjB;Uk7HEHG%<N5(ic=001gQ7x@4H

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 
0000000000000000000000000000000000000000..37354938f876163854465bfb332b08a6c1c5ffac
GIT binary patch
literal 146
zcmca|c+)~A1{MYw`2U}Qff2}Qc;FnKl*Pl41!RM;ppvmmXxggXXYRiH&%xlzzz_q{
z@t<w^OfCinCLm@!!pyK4BnAQjK>Y4JP#z61m@ollBpnzT83LFXxR`*v|NnsauLCp7
M8o>ZBi32Mb0Ma8ZdH?_b

literal 0
HcmV?d00001

diff --git a/ryu/tests/unit/packet/test_bgp.py 
b/ryu/tests/unit/packet/test_bgp.py
index 17bef87..b3c1198 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,
-- 
2.7.4


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to