diff options
author | Ole Troan <ot@cisco.com> | 2017-10-20 13:28:20 +0200 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2017-10-25 17:16:56 +0000 |
commit | 895b6e8b4408108a9b5cea99dcb378c3524b18b2 (patch) | |
tree | e9100c39d04dfa65469e8c9895c8e3d1fe44c394 /test | |
parent | 5f3fcb96296a4769f55f60270e10c6294c604db9 (diff) |
VPP-1033: Python API support arbitrary sized input parameters.
Dynamically calculate the required buffer size to pack into based on
message definition. Also add input parameter length checking.
Change-Id: I7633bec596e4833bb328fbf63a65b866c7985de5
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/test_acl_plugin.py | 4 | ||||
-rw-r--r-- | test/test_dhcp.py | 3 | ||||
-rw-r--r-- | test/test_nat.py | 17 | ||||
-rw-r--r-- | test/test_papi.py | 31 | ||||
-rw-r--r-- | test/vpp_papi_provider.py | 4 |
5 files changed, 47 insertions, 12 deletions
diff --git a/test/test_acl_plugin.py b/test/test_acl_plugin.py index 97fca1a1bb3..cd375a2cea7 100644 --- a/test/test_acl_plugin.py +++ b/test/test_acl_plugin.py @@ -532,7 +532,7 @@ class TestACLplugin(VppTestCase): r[i_rule][rule_key]) # Add a deny-1234 ACL - r_deny = ({'is_permit': 0, 'is_ipv6': 0, 'proto': 17, + r_deny = [{'is_permit': 0, 'is_ipv6': 0, 'proto': 17, 'srcport_or_icmptype_first': 1234, 'srcport_or_icmptype_last': 1235, 'src_ip_prefix_len': 0, @@ -549,7 +549,7 @@ class TestACLplugin(VppTestCase): 'dstport_or_icmpcode_first': 0, 'dstport_or_icmpcode_last': 0, 'dst_ip_addr': '\x00\x00\x00\x00', - 'dst_ip_prefix_len': 0}) + 'dst_ip_prefix_len': 0}] reply = self.vapi.acl_add_replace(acl_index=4294967295, r=r_deny, tag="deny 1234;permit all") diff --git a/test/test_dhcp.py b/test/test_dhcp.py index fe97f6c9a2b..42b80af35d7 100644 --- a/test/test_dhcp.py +++ b/test/test_dhcp.py @@ -19,6 +19,7 @@ from scapy.layers.dhcp6 import DHCP6, DHCP6_Solicit, DHCP6_RelayForward, \ from socket import AF_INET, AF_INET6 from scapy.utils import inet_pton, inet_ntop from scapy.utils6 import in6_ptop +from util import mactobinary DHCP4_CLIENT_PORT = 68 DHCP4_SERVER_PORT = 67 @@ -1134,7 +1135,7 @@ class TestDHCP(VppTestCase): # remove the left over ARP entry self.vapi.ip_neighbor_add_del(self.pg2.sw_if_index, - self.pg2.remote_mac, + mactobinary(self.pg2.remote_mac), self.pg2.remote_ip4, is_add=0) # diff --git a/test/test_nat.py b/test/test_nat.py index 2afa1dd26df..792b21b418f 100644 --- a/test/test_nat.py +++ b/test/test_nat.py @@ -16,6 +16,7 @@ from util import ppp from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder from time import sleep from util import ip4_range +from util import mactobinary class MethodHolder(VppTestCase): @@ -659,7 +660,9 @@ class TestNAT44(MethodHolder): lb_sm.external_port, lb_sm.protocol, lb_sm.vrf_id, - is_add=0) + is_add=0, + local_num=0, + locals=[]) adresses = self.vapi.nat44_address_dump() for addr in adresses: @@ -1885,11 +1888,11 @@ class TestNAT44(MethodHolder): """ NAT44 interfaces without configured IP address """ self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index, - self.pg7.remote_mac, + mactobinary(self.pg7.remote_mac), self.pg7.remote_ip4n, is_static=1) self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index, - self.pg8.remote_mac, + mactobinary(self.pg8.remote_mac), self.pg8.remote_ip4n, is_static=1) @@ -1927,11 +1930,11 @@ class TestNAT44(MethodHolder): """ NAT44 interfaces without configured IP address - 1:1 NAT """ self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index, - self.pg7.remote_mac, + mactobinary(self.pg7.remote_mac), self.pg7.remote_ip4n, is_static=1) self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index, - self.pg8.remote_mac, + mactobinary(self.pg8.remote_mac), self.pg8.remote_ip4n, is_static=1) @@ -1973,11 +1976,11 @@ class TestNAT44(MethodHolder): self.icmp_id_out = 30608 self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index, - self.pg7.remote_mac, + mactobinary(self.pg7.remote_mac), self.pg7.remote_ip4n, is_static=1) self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index, - self.pg8.remote_mac, + mactobinary(self.pg8.remote_mac), self.pg8.remote_ip4n, is_static=1) diff --git a/test/test_papi.py b/test/test_papi.py new file mode 100644 index 00000000000..1a5f6ae63e4 --- /dev/null +++ b/test/test_papi.py @@ -0,0 +1,31 @@ +import binascii +from framework import VppTestCase + +""" TestPAPI is a subclass of VPPTestCase classes. + +Basic test for sanity check of the Python API binding. + +""" + + +class TestPAPI(VppTestCase): + """ PAPI Test Case """ + + @classmethod + def setUpClass(cls): + super(TestPAPI, cls).setUpClass() + cls.v = cls.vapi.papi + + def test_show_version(self): + rv = self.v.show_version() + self.assertEqual(rv.retval, 0) + + def test_show_version_invalid_param(self): + self.assertRaises(ValueError, self.v.show_version, foobar='foo') + + def test_u8_array(self): + rv = self.v.get_node_index(node_name='ip4-lookup') + self.assertEqual(rv.retval, 0) + node_name = 'X' * 100 + self.assertRaises(ValueError, self.v.get_node_index, + node_name=node_name) diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index 2e970d24704..68b2bd0b514 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -1323,7 +1323,7 @@ class VppPapiProvider(object): protocol, vrf_id=0, local_num=0, - locals=None, + locals=[], is_add=1): """Add/delete NAT44 load balancing static mapping @@ -2037,7 +2037,7 @@ class VppPapiProvider(object): eid, eid_prefix_len=0, vni=0, - rlocs=None, + rlocs=[], rlocs_num=0, is_src_dst=0, is_add=1): |