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 |
Pratikshya Prasai | 657bdf7 | 2022-08-18 11:09:38 -0400 | [diff] [blame] | 6 | from asfframework 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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 11 | """Bihash Test Cases""" |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 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) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 39 | """Bihash Thread Test""" |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 40 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 41 | error = self.vapi.cli( |
| 42 | "test bihash threads 2 nbuckets" + " 64000 careful 0 verbose 0" |
| 43 | ) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 44 | |
| 45 | if error: |
| 46 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 47 | self.assertNotIn("failed", error) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 48 | |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 49 | def test_bihash_vec64(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 50 | """Bihash vec64 Test""" |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 51 | |
| 52 | error = self.vapi.cli("test bihash vec64") |
| 53 | |
| 54 | if error: |
| 55 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 56 | self.assertNotIn("failed", error) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 57 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 58 | @unittest.skipUnless(config.gcov, "part of code coverage tests") |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 59 | def test_bihash_coverage(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 60 | """Improve Code Coverage""" |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 61 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 62 | error = self.vapi.cli( |
| 63 | "test bihash nitems 10 ncycles 3" |
| 64 | + "search 2 careful 1 verbose 2 non-random-keys" |
| 65 | ) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 66 | |
| 67 | if error: |
| 68 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 69 | self.assertNotIn("failed", error) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 70 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 71 | error = self.vapi.cli( |
| 72 | "test bihash nitems 10 nbuckets 1 ncycles 3" |
| 73 | + "search 2 careful 1 verbose 2 non-random-keys" |
| 74 | ) |
Dave Barach | 37b4454 | 2020-04-27 18:38:36 -0400 | [diff] [blame] | 75 | if error: |
| 76 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 77 | self.assertNotIn("failed", error) |
Dave Barach | 37b4454 | 2020-04-27 18:38:36 -0400 | [diff] [blame] | 78 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 79 | |
| 80 | if __name__ == "__main__": |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 81 | unittest.main(testRunner=VppTestRunner) |