Signed-off-by: IWASE Yusuke <[email protected]>
---
ryu/tests/packet_data/pcap/zebra.pcap | Bin 0 -> 1593 bytes
ryu/tests/unit/packet/test_zebra.py | 65 ++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
create mode 100644 ryu/tests/packet_data/pcap/zebra.pcap
create mode 100644 ryu/tests/unit/packet/test_zebra.py
diff --git a/ryu/tests/packet_data/pcap/zebra.pcap
b/ryu/tests/packet_data/pcap/zebra.pcap
new file mode 100644
index
0000000000000000000000000000000000000000..892d700f39fb02132d6ba592db66254190a758e7
GIT binary patch
literal 1593
zcma)6O=uHA6n-<CrpXpe4%!xkMxue9Y`u7DA;f<@Sk@RyZ-Uk$F^#P#1*sAA(o+$<
zco3u)LGa+ggR~$Df?$yrMT%Y|BGMKQQoJ?sy*D$vlTBIr;0?R8oA3MHx8LORyO&QT
z#2}~`2)wyHG&Z_<2;dxEQ`?n*69B`Nk9o+)mpAVM2<o-6+u!+cVs&YuSgrNS=Zzz{
zDH1Nk;`_OiO$SkWk_3G)2XGeesO@6tp~~`((BFLM!4PzUq4yGU0g*=#lG-jtE_l}o
zdHtjj?e?#g2^EFcS@h8m@*YO+mT#WT{5?SU#c1W9Soyla*QV5wW0vuERxSwn8Y0i3
zWNN!u`5mvq%DW7*Rz8c$HyF7ZQhu71iz_!Lkh8612XBe=G4-h9I{>xX#Wn5~;r00y
z4uV_+c!H^*wu_XBd2f=G{r(qH_TDIK-uIQ|FbFy5VPzBs32baHy4!>SYujzq6wyc#
znhn&ESGU$0%!fg1D`z+J&D~nTK>D-}sS*27jj+`?(5eQ1m2cxKD7VX#ZBJ-JXf<$#
zACrxNm3_Qt=@1~v%LMNSt_X0|oBk?l{-wT%4Udif>`O%*+f`2JFY~o@LN}HcN?FX&
zVsLEd-}2W|$F@rn^u<gHE+ZAST^!MpSLKKf7-$vIQWk@-#Sz8RuKp1S8avCTb;@*x
zJZDE}p=78c&a2U!H<<Hqi1YaFIA?rLX(%CyocE^VQ5Jq-3+skcTeyW5j<;I)sGH~1
z77Bv?gV2|djM^@?@PaqR;|v;TZQ(eMv&|NsG8Pgvc1Bq!(isqVirB<pmJ|}c_#mTZ
Z`O35WFob%RZJgyn>nx97F`=Ht`48vh4hR4M
literal 0
HcmV?d00001
diff --git a/ryu/tests/unit/packet/test_zebra.py
b/ryu/tests/unit/packet/test_zebra.py
new file mode 100644
index 0000000..78c494c
--- /dev/null
+++ b/ryu/tests/unit/packet/test_zebra.py
@@ -0,0 +1,65 @@
+# Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import print_function
+
+import os
+import sys
+import unittest
+
+from nose.tools import eq_
+from nose.tools import ok_
+import six
+
+from ryu.lib import pcaplib
+from ryu.lib.packet import packet
+from ryu.lib.packet import zebra
+from ryu.utils import binary_str
+
+
+PCAP_DATA_DIR = os.path.join(
+ os.path.dirname(sys.modules[__name__].__file__),
+ '../../packet_data/pcap/')
+
+
+class Test_zebra(unittest.TestCase):
+ """
+ Test case for ryu.lib.packet.zebra.
+ """
+
+ def test_pcap(self):
+ files = [
+ 'zebra',
+ ]
+
+ for f in files:
+ zebra_pcap_file = os.path.join(PCAP_DATA_DIR, f + '.pcap')
+ # print('*** testing %s' % zebra_pcap_file)
+
+ for _, buf in pcaplib.Reader(open(zebra_pcap_file, 'rb')):
+ # Checks if Zebra message can be parsed as expected.
+ pkt = packet.Packet(buf)
+ zebra_pkts = pkt.get_protocols(zebra.ZebraMessage)
+ for zebra_pkt in zebra_pkts:
+ ok_(isinstance(zebra_pkt, zebra.ZebraMessage),
+ 'Failed to parse Zebra message: %s' % pkt)
+ ok_(not isinstance(pkt.protocols[-1],
+ (six.binary_type, bytearray)),
+ 'Some messages could not be parsed: %s' % pkt)
+
+ # Checks if Zebra message can be serialized as expected.
+ pkt.serialize()
+ eq_(buf, pkt.data,
+ "b'%s' != b'%s'" % (binary_str(buf), binary_str(pkt.data)))
--
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel