Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 5 | from config import config |
| 6 | from framework import VppTestCase, VppTestRunner |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 7 | from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath |
| 8 | |
| 9 | |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 10 | class TestBihash(VppTestCase): |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 11 | """ Bihash Test Cases """ |
| 12 | |
| 13 | @classmethod |
| 14 | def setUpClass(cls): |
Dave Barach | b60620b | 2021-02-10 07:40:05 -0500 | [diff] [blame] | 15 | # increase vapi timeout, to avoid spurious "test bihash ..." |
| 16 | # failures reported on aarch64 w/ test-debug |
| 17 | cls.vapi_response_timeout = 20 |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 18 | super(TestBihash, cls).setUpClass() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 19 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 20 | @classmethod |
| 21 | def tearDownClass(cls): |
| 22 | super(TestBihash, cls).tearDownClass() |
| 23 | |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 24 | def setUp(self): |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 25 | super(TestBihash, self).setUp() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 26 | |
| 27 | def tearDown(self): |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 28 | super(TestBihash, self).tearDown() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 29 | |
| 30 | def test_bihash_unittest(self): |
| 31 | """ Bihash Add/Del Test """ |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 32 | error = self.vapi.cli("test bihash careful 0 verbose 0") |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 33 | |
| 34 | if error: |
| 35 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 36 | self.assertNotIn('failed', error) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 37 | |
| 38 | def test_bihash_thread(self): |
| 39 | """ Bihash Thread Test """ |
| 40 | |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 41 | error = self.vapi.cli("test bihash threads 2 nbuckets" + |
| 42 | " 64000 careful 0 verbose 0") |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 43 | |
| 44 | if error: |
| 45 | self.logger.critical(error) |
Paul Vinciguerra | 9a6dafd | 2019-03-06 15:11:28 -0800 | [diff] [blame] | 46 | self.assertNotIn('failed', error) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 47 | |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 48 | def test_bihash_vec64(self): |
| 49 | """ Bihash vec64 Test """ |
| 50 | |
| 51 | error = self.vapi.cli("test bihash vec64") |
| 52 | |
| 53 | if error: |
| 54 | self.logger.critical(error) |
| 55 | self.assertNotIn('failed', error) |
| 56 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 57 | @unittest.skipUnless(config.gcov, "part of code coverage tests") |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 58 | def test_bihash_coverage(self): |
| 59 | """ Improve Code Coverage """ |
| 60 | |
| 61 | error = self.vapi.cli("test bihash nitems 10 ncycles 3" + |
| 62 | "search 2 careful 1 verbose 2 non-random-keys") |
| 63 | |
| 64 | if error: |
| 65 | self.logger.critical(error) |
| 66 | self.assertNotIn('failed', error) |
| 67 | |
Dave Barach | 37b4454 | 2020-04-27 18:38:36 -0400 | [diff] [blame] | 68 | error = self.vapi.cli("test bihash nitems 10 nbuckets 1 ncycles 3" + |
| 69 | "search 2 careful 1 verbose 2 non-random-keys") |
| 70 | if error: |
| 71 | self.logger.critical(error) |
| 72 | self.assertNotIn('failed', error) |
| 73 | |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 74 | if __name__ == '__main__': |
| 75 | unittest.main(testRunner=VppTestRunner) |