diff options
author | Shinpei Muraoka <shinpei.muraoka@gmail.com> | 2016-06-06 09:48:13 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-09 13:07:35 +0900 |
commit | 5ebf0fa5c4781e73020ebc853bb4ff8f9168bac3 (patch) | |
tree | 67298b59187dff799bd6382307a9e06000c0deed | |
parent | 3c3896fd77f274ce953dcb78795aa5cc4fde6c65 (diff) |
tests/test_parser_v10: Update test parameter
Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/unit/ofproto/test_parser_v10.py | 146 |
1 files changed, 61 insertions, 85 deletions
diff --git a/ryu/tests/unit/ofproto/test_parser_v10.py b/ryu/tests/unit/ofproto/test_parser_v10.py index 5143e119..29bc3157 100644 --- a/ryu/tests/unit/ofproto/test_parser_v10.py +++ b/ryu/tests/unit/ofproto/test_parser_v10.py @@ -1140,15 +1140,13 @@ class TestNXActionResubmit(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.in_port['val'], self.c.in_port) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) eq_(self.in_port['val'], res.in_port) def test_serialize(self): @@ -1176,7 +1174,7 @@ class TestNXActionResubmitTable(unittest.TestCase): vendor = {'buf': b'\x00\x00\x23\x20', 'val': 8992} subtype = {'buf': b'\x00\x0e', 'val': 14} in_port = {'buf': b'\x0a\x4c', 'val': 2636} - table = {'buf': b'\x52', 'val': 82} + table_id = {'buf': b'\x52', 'val': 82} zfill = b'\x00' * 3 buf = type_['buf'] \ @@ -1184,10 +1182,10 @@ class TestNXActionResubmitTable(unittest.TestCase): + vendor['buf'] \ + subtype['buf'] \ + in_port['buf'] \ - + table['buf'] \ + + table_id['buf'] \ + zfill - c = NXActionResubmitTable(in_port['val'], table['val']) + c = NXActionResubmitTable(in_port['val'], table_id['val']) def setUp(self): pass @@ -1196,17 +1194,16 @@ class TestNXActionResubmitTable(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.in_port['val'], self.c.in_port) + eq_(self.table_id['val'], self.c.table_id) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) eq_(self.in_port['val'], res.in_port) - eq_(self.table['val'], res.table) + eq_(self.table_id['val'], res.table_id) def test_serialize(self): buf = bytearray() @@ -1220,6 +1217,7 @@ class TestNXActionResubmitTable(unittest.TestCase): eq_(self.vendor['val'], res[2]) eq_(self.subtype['val'], res[3]) eq_(self.in_port['val'], res[4]) + eq_(self.table_id['val'], res[5]) class TestNXActionSetTunnel(unittest.TestCase): @@ -1251,14 +1249,13 @@ class TestNXActionSetTunnel(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.tun_id['val'], self.c.tun_id) - def test_parser(self): - res = self.c.parser(self.buf, 0) + def test_parse(self): + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) eq_(self.tun_id['val'], res.tun_id) def test_serialize(self): @@ -1303,16 +1300,12 @@ class TestNXActionPopQueue(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) def test_parser(self): - res = self.c.parser(self.buf, 0) + res = OFPActionVendor.parser(self.buf, 0) eq_(self.type_['val'], res.type) eq_(self.len_['val'], res.len) - eq_(self.vendor['val'], res.vendor) eq_(self.subtype['val'], res.subtype) def test_serialize(self): @@ -1343,8 +1336,8 @@ class TestNXActionRegMove(unittest.TestCase): n_bits = {'buf': b'\x3d\x98', 'val': 15768} src_ofs = {'buf': b'\xf3\xa3', 'val': 62371} dst_ofs = {'buf': b'\xdc\x67', 'val': 56423} - src = {'buf': b'\x15\x68\x60\xfd', 'val': 359162109} - dst = {'buf': b'\x9f\x9f\x88\x26', 'val': 2678032422} + src_field = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", "val2": 65540} + dst_field = {'buf': b'\x00\x01\x02\x04', 'val': "reg1", "val2": 66052} buf = type_['buf'] \ + len_['buf'] \ @@ -1353,14 +1346,14 @@ class TestNXActionRegMove(unittest.TestCase): + n_bits['buf'] \ + src_ofs['buf'] \ + dst_ofs['buf'] \ - + src['buf'] \ - + dst['buf'] + + src_field['buf'] \ + + dst_field['buf'] - c = NXActionRegMove(n_bits['val'], + c = NXActionRegMove(src_field['val'], + dst_field['val'], + n_bits['val'], src_ofs['val'], - dst_ofs['val'], - src['val'], - dst['val']) + dst_ofs['val']) def setUp(self): pass @@ -1369,23 +1362,23 @@ class TestNXActionRegMove(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.n_bits['val'], self.c.n_bits) eq_(self.src_ofs['val'], self.c.src_ofs) eq_(self.dst_ofs['val'], self.c.dst_ofs) - eq_(self.src['val'], self.c.src) - eq_(self.dst['val'], self.c.dst) + eq_(self.src_field['val'], self.c.src_field) + eq_(self.dst_field['val'], self.c.dst_field) def test_parser(self): - res = self.c.parser(self.buf, 0) + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) + eq_(self.subtype['val'], res.subtype) eq_(self.n_bits['val'], res.n_bits) eq_(self.src_ofs['val'], res.src_ofs) eq_(self.dst_ofs['val'], res.dst_ofs) - eq_(self.src['val'], res.src) - eq_(self.dst['val'], res.dst) + eq_(self.src_field['val'], res.src_field) + eq_(self.dst_field['val'], res.dst_field) def test_serialize(self): buf = bytearray() @@ -1401,8 +1394,8 @@ class TestNXActionRegMove(unittest.TestCase): eq_(self.n_bits['val'], res[4]) eq_(self.src_ofs['val'], res[5]) eq_(self.dst_ofs['val'], res[6]) - eq_(self.src['val'], res[7]) - eq_(self.dst['val'], res[8]) + eq_(self.src_field['val2'], res[7]) + eq_(self.dst_field['val2'], res[8]) class TestNXActionRegLoad(unittest.TestCase): @@ -1418,7 +1411,7 @@ class TestNXActionRegLoad(unittest.TestCase): 'val': ofproto_common.NX_EXPERIMENTER_ID} subtype = {'buf': b'\x00\x07', 'val': ofproto.NXAST_REG_LOAD} ofs_nbits = {'buf': b'\x3d\x98', 'val': 15768} - dst = {'buf': b'\x9f\x9f\x88\x26', 'val': 2678032422} + dst = {'buf': b'\x00\x01\x00\x04', 'val': "reg0", "val2": 65540} value = {'buf': b'\x33\x51\xcd\x43\x25\x28\x18\x99', 'val': 3697962457317775513} start = 246 @@ -1444,9 +1437,6 @@ class TestNXActionRegLoad(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.start, self.c.start) eq_(self.end, self.c.end) @@ -1454,7 +1444,9 @@ class TestNXActionRegLoad(unittest.TestCase): eq_(self.value['val'], self.c.value) def test_parser(self): - res = self.c.parser(self.buf, 0) + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) eq_(self.start, self.c.start) eq_(self.end, self.c.end) eq_(self.dst['val'], res.dst) @@ -1472,7 +1464,7 @@ class TestNXActionRegLoad(unittest.TestCase): eq_(self.vendor['val'], res[2]) eq_(self.subtype['val'], res[3]) eq_(self.ofs_nbits['val'], res[4]) - eq_(self.dst['val'], res[5]) + eq_(self.dst['val2'], res[5]) eq_(self.value['val'], res[6]) @@ -1507,15 +1499,15 @@ class TestNXActionSetTunnel64(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.tun_id['val'], self.c.tun_id) def test_parser(self): - res = self.c.parser(self.buf, 0) - eq_(self.tun_id['val'], self.c.tun_id) + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) + eq_(self.subtype['val'], res.subtype) + eq_(self.tun_id['val'], res.tun_id) def test_serialize(self): buf = bytearray() @@ -1585,6 +1577,7 @@ class TestNXActionMultipath(unittest.TestCase): pass def test_init(self): + eq_(self.subtype['val'], self.c.subtype) eq_(self.fields['val'], self.c.fields) eq_(self.basis['val'], self.c.basis) eq_(self.algorithm['val'], self.c.algorithm) @@ -1595,8 +1588,10 @@ class TestNXActionMultipath(unittest.TestCase): eq_(self.dst['val'], self.c.dst) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) + eq_(self.type_['val'], res.type) + eq_(self.len_['val'], res.len) + eq_(self.subtype['val'], res.subtype) eq_(self.fields['val'], res.fields) eq_(self.basis['val'], res.basis) eq_(self.algorithm['val'], res.algorithm) @@ -1635,7 +1630,7 @@ class TestNXActionBundle(unittest.TestCase): # fields, basis, slave_type, n_slaves, # ofs_nbits, dst, zfill type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR} - len_ = {'buf': b'\x00\x20', 'val': ofproto.NX_ACTION_BUNDLE_SIZE} + len_ = {'buf': b'\x00\x28', 'val': (ofproto.NX_ACTION_BUNDLE_SIZE + 8)} vendor = {'buf': b'\x00\x00\x23\x20', 'val': ofproto_common.NX_EXPERIMENTER_ID} subtype = {'buf': b'\x00\x0c', 'val': ofproto.NXAST_BUNDLE} @@ -1688,9 +1683,6 @@ class TestNXActionBundle(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self._len, self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.algorithm['val'], self.c.algorithm) eq_(self.fields['val'], self.c.fields) @@ -1707,11 +1699,9 @@ class TestNXActionBundle(unittest.TestCase): eq_(self.slaves_val[1], slaves[1]) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) eq_(self.type_['val'], res.type) - eq_(self._len, res.len) - eq_(self.vendor['val'], res.vendor) + eq_(self.len_['val'], res.len) eq_(self.subtype['val'], res.subtype) eq_(self.algorithm['val'], res.algorithm) eq_(self.fields['val'], res.fields) @@ -1738,7 +1728,7 @@ class TestNXActionBundle(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(buf)) eq_(self.type_['val'], res[0]) - eq_(self._len, res[1]) + eq_(self.len_['val'], res[1]) eq_(self.vendor['val'], res[2]) eq_(self.subtype['val'], res[3]) eq_(self.algorithm['val'], res[4]) @@ -1759,7 +1749,7 @@ class TestNXActionBundleLoad(unittest.TestCase): # fields, basis, slave_type, n_slaves, # ofs_nbits, dst, zfill type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR} - len_ = {'buf': b'\x00\x20', 'val': ofproto.NX_ACTION_BUNDLE_SIZE} + len_ = {'buf': b'\x00\x28', 'val': (ofproto.NX_ACTION_BUNDLE_SIZE + 8)} vendor = {'buf': b'\x00\x00\x23\x20', 'val': ofproto_common.NX_EXPERIMENTER_ID} subtype = {'buf': b'\x00\x0d', 'val': ofproto.NXAST_BUNDLE_LOAD} @@ -1812,9 +1802,6 @@ class TestNXActionBundleLoad(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self._len, self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.algorithm['val'], self.c.algorithm) eq_(self.fields['val'], self.c.fields) @@ -1831,11 +1818,9 @@ class TestNXActionBundleLoad(unittest.TestCase): eq_(self.slaves_val[1], slaves[1]) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) eq_(self.type_['val'], res.type) - eq_(self._len, res.len) - eq_(self.vendor['val'], res.vendor) + eq_(self.len_['val'], res.len) eq_(self.subtype['val'], res.subtype) eq_(self.algorithm['val'], res.algorithm) eq_(self.fields['val'], res.fields) @@ -1862,7 +1847,7 @@ class TestNXActionBundleLoad(unittest.TestCase): res = struct.unpack(fmt, six.binary_type(buf)) eq_(self.type_['val'], res[0]) - eq_(self._len, res[1]) + eq_(self.len_['val'], res[1]) eq_(self.vendor['val'], res[2]) eq_(self.subtype['val'], res[3]) eq_(self.algorithm['val'], res[4]) @@ -1882,7 +1867,7 @@ class TestNXActionOutputReg(unittest.TestCase): # '!HHIHHIH6x'...type, len, vendor, subtype, ofs_nbits, # src, max_len, zfill type_ = {'buf': b'\xff\xff', 'val': ofproto.OFPAT_VENDOR} - len_ = {'buf': b'\x00\x20', 'val': ofproto.NX_ACTION_OUTPUT_REG_SIZE} + len_ = {'buf': b'\x00\x18', 'val': ofproto.NX_ACTION_OUTPUT_REG_SIZE} vendor = {'buf': b'\x00\x00\x23\x20', 'val': ofproto_common.NX_EXPERIMENTER_ID} subtype = {'buf': b'\x00\x0f', 'val': ofproto.NXAST_OUTPUT_REG} @@ -1914,9 +1899,6 @@ class TestNXActionOutputReg(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) eq_(self.start, self.c.start) eq_(self.end, self.c.end) @@ -1924,11 +1906,9 @@ class TestNXActionOutputReg(unittest.TestCase): eq_(self.max_len['val'], self.c.max_len) def test_parser(self): - res = self.c.parser(self.buf, 0) - + res = OFPActionVendor.parser(self.buf, 0) eq_(self.type_['val'], res.type) eq_(self.len_['val'], res.len) - eq_(self.vendor['val'], res.vendor) eq_(self.subtype['val'], res.subtype) eq_(self.start, self.c.start) eq_(self.end, self.c.end) @@ -1979,16 +1959,12 @@ class TestNXActionExit(unittest.TestCase): pass def test_init(self): - eq_(self.type_['val'], self.c.type) - eq_(self.len_['val'], self.c.len) - eq_(self.vendor['val'], self.c.vendor) eq_(self.subtype['val'], self.c.subtype) def test_parser(self): - res = self.c.parser(self.buf, 0) + res = OFPActionVendor.parser(self.buf, 0) eq_(self.type_['val'], res.type) eq_(self.len_['val'], res.len) - eq_(self.vendor['val'], res.vendor) eq_(self.subtype['val'], res.subtype) def test_serialize(self): |