Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Tests: Refactor payload_to_info()
[vpp.git]
/
test
/
test_classifier.py
diff --git
a/test/test_classifier.py
b/test/test_classifier.py
index
ade9673
..
f62a76d
100644
(file)
--- a/
test/test_classifier.py
+++ b/
test/test_classifier.py
@@
-1,9
+1,8
@@
#!/usr/bin/env python
#!/usr/bin/env python
-import unittest
-import socket
import binascii
import binascii
-import sys
+import socket
+import unittest
from framework import VppTestCase, VppTestRunner
from framework import VppTestCase, VppTestRunner
@@
-142,7
+141,7
@@
class TestClassifier(VppTestCase):
try:
ip_received = packet[IP]
proto_received = packet[proto_l]
try:
ip_received = packet[IP]
proto_received = packet[proto_l]
- payload_info = self.payload_to_info(
str(packet[Raw])
)
+ payload_info = self.payload_to_info(
packet[Raw]
)
packet_index = payload_info.index
self.assertEqual(payload_info.dst, dst_sw_if_index)
self.logger.debug(
packet_index = payload_info.index
self.assertEqual(payload_info.dst, dst_sw_if_index)
self.logger.debug(
@@
-203,7
+202,7
@@
class TestClassifier(VppTestCase):
:param str dst_port: destination port number <0-ffff>
"""
:param str dst_port: destination port number <0-ffff>
"""
- return ('{
:0>20}{:0>12}{:0>8}{:0>4}{
:0>4}'.format(
+ return ('{
!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s
:0>4}'.format(
proto, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
proto, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
@@
-218,11
+217,11
@@
class TestClassifier(VppTestCase):
:param int dst_port: destination port number "x"
"""
if src_ip:
:param int dst_port: destination port number "x"
"""
if src_ip:
- src_ip =
socket.inet_aton(src_ip).encode('hex'
)
+ src_ip =
binascii.hexlify(socket.inet_aton(src_ip)
)
if dst_ip:
if dst_ip:
- dst_ip =
socket.inet_aton(dst_ip).encode('hex'
)
+ dst_ip =
binascii.hexlify(socket.inet_aton(dst_ip)
)
- return ('{
:0>20}{:0>12}{:0>8}{:0>4}{
:0>4}'.format(
+ return ('{
!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s
:0>4}'.format(
hex(proto)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
hex(proto)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
@@
-235,8
+234,8
@@
class TestClassifier(VppTestCase):
:param str ether_type: ethernet type <0-ffff>
"""
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{
:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
-
ether_type)).rstrip('0')
+ return ('{
!s:0>12}{!s:0>12}{!s:0>4}'.format(
+
dst_mac, src_mac,
ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
@@
-251,8
+250,8
@@
class TestClassifier(VppTestCase):
if src_mac:
src_mac = src_mac.replace(':', '')
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{
:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
-
ether_type)).rstrip('0')
+ return ('{
!s:0>12}{!s:0>12}{!s:0>4}'.format(
+
dst_mac, src_mac,
ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
@@
-268,7
+267,7
@@
class TestClassifier(VppTestCase):
miss_next_index=0,
current_data_flag=1,
current_data_offset=data_offset)
miss_next_index=0,
current_data_flag=1,
current_data_offset=data_offset)
- self.assertIsNotNone(r,
msg=
'No response msg for add_del_table')
+ self.assertIsNotNone(r, 'No response msg for add_del_table')
self.acl_tbl_idx[key] = r.new_table_index
def create_classify_session(self, table_index, match, pbr_option=0,
self.acl_tbl_idx[key] = r.new_table_index
def create_classify_session(self, table_index, match, pbr_option=0,
@@
-289,7
+288,7
@@
class TestClassifier(VppTestCase):
opaque_index=0,
action=pbr_option,
metadata=vrfid)
opaque_index=0,
action=pbr_option,
metadata=vrfid)
- self.assertIsNotNone(r,
msg=
'No response msg for add_del_session')
+ self.assertIsNotNone(r, 'No response msg for add_del_session')
def input_acl_set_interface(self, intf, table_index, is_add=1):
"""Configure Input ACL interface
def input_acl_set_interface(self, intf, table_index, is_add=1):
"""Configure Input ACL interface
@@
-303,7
+302,7
@@
class TestClassifier(VppTestCase):
is_add,
intf.sw_if_index,
ip4_table_index=table_index)
is_add,
intf.sw_if_index,
ip4_table_index=table_index)
- self.assertIsNotNone(r,
msg=
'No response msg for acl_set_interface')
+ self.assertIsNotNone(r, 'No response msg for acl_set_interface')
def output_acl_set_interface(self, intf, table_index, is_add=1):
"""Configure Output ACL interface
def output_acl_set_interface(self, intf, table_index, is_add=1):
"""Configure Output ACL interface
@@
-317,7
+316,7
@@
class TestClassifier(VppTestCase):
is_add,
intf.sw_if_index,
ip4_table_index=table_index)
is_add,
intf.sw_if_index,
ip4_table_index=table_index)
- self.assertIsNotNone(r,
msg=
'No response msg for acl_set_interface')
+ self.assertIsNotNone(r, 'No response msg for acl_set_interface')
# Tests split to different test case classes because of issue reported in
# Tests split to different test case classes because of issue reported in