ofproto: remove some assertions

remove some assertions which merely prevent serializing an object
multiple times.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
YAMAMOTO Takashi
2013-09-02 12:09:52 +09:00
committed by FUJITA Tomonori
parent 915b3be519
commit 79ee99e98e
3 changed files with 1 additions and 36 deletions

View File

@@ -126,10 +126,6 @@ class MsgBase(StringifyMixin):
return msg_
def _serialize_pre(self):
assert self.version is None
assert self.msg_type is None
assert self.buf is None
self.version = self.datapath.ofproto.OFP_VERSION
self.msg_type = self.cls_msg_type
self.buf = bytearray(self.datapath.ofproto.OFP_HEADER_SIZE)
@@ -138,7 +134,6 @@ class MsgBase(StringifyMixin):
# buffer length is determined after trailing data is formated.
assert self.version is not None
assert self.msg_type is not None
assert self.msg_len is None
assert self.buf is not None
assert len(self.buf) >= self.datapath.ofproto.OFP_HEADER_SIZE

View File

@@ -2081,7 +2081,6 @@ class OFPPacketOut(MsgBase):
def _serialize_body(self):
assert self.buffer_id is not None
assert self.in_port is not None
assert self._actions_len is None
assert self.actions is not None
self._actions_len = 0

View File

@@ -204,8 +204,7 @@ class TestMsgBase(unittest.TestCase):
def test_parser_check_msg_type(self):
self._test_parser(ofproto_v1_0.OFPT_ERROR)
def _test_serialize(self, version=True, msg_type=True,
msg_len=True, buf=True):
def _test_serialize(self):
class Datapath(object):
ofproto = ofproto_v1_0
@@ -213,18 +212,6 @@ class TestMsgBase(unittest.TestCase):
c = ofproto_v1_0_parser.OFPHello(Datapath)
if not version:
c.version = ofproto_v1_0.OFP_VERSION
if not msg_type:
c.msg_type = ofproto_v1_0.OFPT_HELLO
if not msg_len:
c.msg_len = ofproto_v1_0.OFP_HEADER_PACK_STR
if not buf:
c.buf = bytearray()
c.serialize()
eq_(ofproto_v1_0.OFP_VERSION, c.version)
eq_(ofproto_v1_0.OFPT_HELLO, c.msg_type)
@@ -235,22 +222,6 @@ class TestMsgBase(unittest.TestCase):
def test_serialize(self):
ok_(self._test_serialize())
@raises(AssertionError)
def test_serialize_check_version(self):
self._test_serialize(version=False)
@raises(AssertionError)
def test_serialize_check_msg_type(self):
self._test_serialize(msg_type=False)
@raises(AssertionError)
def test_serialize_check_msg_len(self):
self._test_serialize(msg_len=False)
@raises(AssertionError)
def test_serialize_check_buf(self):
self._test_serialize(buf=False)
class TestMsgPackInto(unittest.TestCase):
""" Test case for ofproto_parser.msg_pack_into