Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 1 | import binascii |
| 2 | from framework import VppTestCase |
Ole Troan | ca3b6f1 | 2017-10-31 14:50:13 +0100 | [diff] [blame] | 3 | from vpp_papi import VPP |
Ole Troan | a5ee900 | 2018-06-12 21:06:44 +0200 | [diff] [blame^] | 4 | from socket import inet_pton, AF_INET, AF_INET6 |
| 5 | |
Ole Troan | ca3b6f1 | 2017-10-31 14:50:13 +0100 | [diff] [blame] | 6 | import json |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 7 | |
| 8 | """ TestPAPI is a subclass of VPPTestCase classes. |
| 9 | |
| 10 | Basic test for sanity check of the Python API binding. |
| 11 | |
| 12 | """ |
| 13 | |
| 14 | |
| 15 | class TestPAPI(VppTestCase): |
| 16 | """ PAPI Test Case """ |
| 17 | |
| 18 | @classmethod |
| 19 | def setUpClass(cls): |
| 20 | super(TestPAPI, cls).setUpClass() |
| 21 | cls.v = cls.vapi.papi |
| 22 | |
| 23 | def test_show_version(self): |
Ole Troan | 034e055 | 2017-12-14 11:28:21 +0100 | [diff] [blame] | 24 | """ show version """ |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 25 | rv = self.v.show_version() |
| 26 | self.assertEqual(rv.retval, 0) |
| 27 | |
| 28 | def test_show_version_invalid_param(self): |
Ole Troan | 034e055 | 2017-12-14 11:28:21 +0100 | [diff] [blame] | 29 | """ show version - invalid parameters""" |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 30 | self.assertRaises(ValueError, self.v.show_version, foobar='foo') |
| 31 | |
| 32 | def test_u8_array(self): |
Ole Troan | 034e055 | 2017-12-14 11:28:21 +0100 | [diff] [blame] | 33 | """ u8 array """ |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 34 | rv = self.v.get_node_index(node_name='ip4-lookup') |
| 35 | self.assertEqual(rv.retval, 0) |
| 36 | node_name = 'X' * 100 |
| 37 | self.assertRaises(ValueError, self.v.get_node_index, |
| 38 | node_name=node_name) |