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 |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 6 | from asfframework import VppAsfTestCase, VppTestRunner |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 7 | |
| 8 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 9 | class TestBihash(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 10 | """Bihash Test Cases""" |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 11 | |
| 12 | @classmethod |
| 13 | def setUpClass(cls): |
Dave Barach | b60620b | 2021-02-10 07:40:05 -0500 | [diff] [blame] | 14 | # increase vapi timeout, to avoid spurious "test bihash ..." |
| 15 | # failures reported on aarch64 w/ test-debug |
| 16 | cls.vapi_response_timeout = 20 |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 17 | super(TestBihash, cls).setUpClass() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 18 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 19 | @classmethod |
| 20 | def tearDownClass(cls): |
| 21 | super(TestBihash, cls).tearDownClass() |
| 22 | |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 23 | def setUp(self): |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 24 | super(TestBihash, self).setUp() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 25 | |
| 26 | def tearDown(self): |
juraj.linkes | 8e26f6d | 2018-09-19 14:59:43 +0200 | [diff] [blame] | 27 | super(TestBihash, self).tearDown() |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 28 | |
| 29 | def test_bihash_unittest(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 30 | """Bihash Add/Del Test""" |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 31 | error = self.vapi.cli("test bihash careful 0 verbose 0") |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 32 | |
| 33 | if error: |
| 34 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 35 | self.assertNotIn("failed", error) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 36 | |
| 37 | def test_bihash_thread(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 38 | """Bihash Thread Test""" |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 39 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 40 | error = self.vapi.cli( |
| 41 | "test bihash threads 2 nbuckets" + " 64000 careful 0 verbose 0" |
| 42 | ) |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 43 | |
| 44 | if error: |
| 45 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 49 | """Bihash vec64 Test""" |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 50 | |
| 51 | error = self.vapi.cli("test bihash vec64") |
| 52 | |
| 53 | if error: |
| 54 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 55 | self.assertNotIn("failed", error) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 59 | """Improve Code Coverage""" |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 60 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 61 | error = self.vapi.cli( |
| 62 | "test bihash nitems 10 ncycles 3" |
| 63 | + "search 2 careful 1 verbose 2 non-random-keys" |
| 64 | ) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 65 | |
| 66 | if error: |
| 67 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 68 | self.assertNotIn("failed", error) |
Dave Barach | 749a89c | 2019-05-07 10:30:18 -0400 | [diff] [blame] | 69 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 70 | error = self.vapi.cli( |
| 71 | "test bihash nitems 10 nbuckets 1 ncycles 3" |
| 72 | + "search 2 careful 1 verbose 2 non-random-keys" |
| 73 | ) |
Dave Barach | 37b4454 | 2020-04-27 18:38:36 -0400 | [diff] [blame] | 74 | if error: |
| 75 | self.logger.critical(error) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 76 | self.assertNotIn("failed", error) |
Dave Barach | 37b4454 | 2020-04-27 18:38:36 -0400 | [diff] [blame] | 77 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 78 | |
| 79 | if __name__ == "__main__": |
Dave Barach | 8b5dc4f | 2018-07-23 18:00:54 -0400 | [diff] [blame] | 80 | unittest.main(testRunner=VppTestRunner) |