summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/rpm/vpp.spec1
-rw-r--r--src/vpp-api/python/setup.py2
-rw-r--r--src/vpp-api/python/tests/__init__.py0
-rwxr-xr-xsrc/vpp-api/python/tests/test_vpp_serializer.py8
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py6
5 files changed, 8 insertions, 9 deletions
diff --git a/extras/rpm/vpp.spec b/extras/rpm/vpp.spec
index 69d4d6b1cb1..4915914c074 100644
--- a/extras/rpm/vpp.spec
+++ b/extras/rpm/vpp.spec
@@ -398,6 +398,7 @@ fi
%files api-python
%defattr(644,root,root)
%{python2_sitelib}/vpp_*
+%{python2_sitelib}/tests/*
%files selinux-policy
%defattr(-,root,root,0755)
diff --git a/src/vpp-api/python/setup.py b/src/vpp-api/python/setup.py
index d97e35fa98f..130967f79f1 100644
--- a/src/vpp-api/python/setup.py
+++ b/src/vpp-api/python/setup.py
@@ -18,7 +18,7 @@ except ImportError:
from distutils.core import setup, find_packages
setup(name='vpp_papi',
- version='1.5',
+ version='1.6',
description='VPP Python binding',
author='Ole Troan',
author_email='ot@cisco.com',
diff --git a/src/vpp-api/python/tests/__init__.py b/src/vpp-api/python/tests/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/src/vpp-api/python/tests/__init__.py
diff --git a/src/vpp-api/python/tests/test_vpp_serializer.py b/src/vpp-api/python/tests/test_vpp_serializer.py
index 0c194b46d22..9fee161684d 100755
--- a/src/vpp-api/python/tests/test_vpp_serializer.py
+++ b/src/vpp-api/python/tests/test_vpp_serializer.py
@@ -15,11 +15,11 @@ class TestAddType(unittest.TestCase):
[['u8', 'is_bool'],
['u32', 'is_int']])
- b = un.pack({'is_int': 0x1234})
+ b = un.pack({'is_int': 0x12345678})
self.assertEqual(len(b), 4)
nt = un.unpack(b)
- self.assertEqual(nt.is_bool, 52)
- self.assertEqual(nt.is_int, 0x1234)
+ self.assertEqual(nt.is_bool, 0x12)
+ self.assertEqual(nt.is_int, 0x12345678)
def test_address(self):
af = VPPEnumType('vl_api_address_family_t', [["ADDRESS_IP4", 0],
@@ -53,7 +53,7 @@ class TestAddType(unittest.TestCase):
self.assertEqual(nt.un.ip4.address,
inet_pton(AF_INET, '2.2.2.2'))
self.assertEqual(nt.un.ip6.address,
- inet_pton(AF_INET6, '::0202:0202'))
+ inet_pton(AF_INET6, '0202:0202::'))
def test_arrays(self):
# Test cases
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index 9b30d5caa56..cd9a281964a 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -232,17 +232,15 @@ class VPPUnionType():
for k, v in data.items():
logger.debug("Key: {} Value: {}".format(k, v))
b = self.packers[k].pack(v, kwargs)
- offset = self.size - self.packers[k].size
break
r = bytearray(self.size)
- r[offset:] = b
+ r[:len(b)] = b
return r
def unpack(self, data, offset=0, result=None):
r = []
for k, p in self.packers.items():
- union_offset = self.size - p.size
- r.append(p.unpack(data, offset + union_offset))
+ r.append(p.unpack(data, offset))
return self.tuple._make(r)