blob: b7df894be05c25371cdfccba56df0139c6a6a769 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Dave Barach8b5dc4f2018-07-23 18:00:54 -04002
3import unittest
4
Klement Sekerab23ffd72021-05-31 16:08:53 +02005from config import config
Dave Wallace8800f732023-08-31 00:47:44 -04006from asfframework import VppAsfTestCase, VppTestRunner
Dave Barach8b5dc4f2018-07-23 18:00:54 -04007
8
Dave Wallace8800f732023-08-31 00:47:44 -04009class TestBihash(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020010 """Bihash Test Cases"""
Dave Barach8b5dc4f2018-07-23 18:00:54 -040011
12 @classmethod
13 def setUpClass(cls):
Dave Barachb60620b2021-02-10 07:40:05 -050014 # increase vapi timeout, to avoid spurious "test bihash ..."
15 # failures reported on aarch64 w/ test-debug
16 cls.vapi_response_timeout = 20
juraj.linkes8e26f6d2018-09-19 14:59:43 +020017 super(TestBihash, cls).setUpClass()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040018
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070019 @classmethod
20 def tearDownClass(cls):
21 super(TestBihash, cls).tearDownClass()
22
Dave Barach8b5dc4f2018-07-23 18:00:54 -040023 def setUp(self):
juraj.linkes8e26f6d2018-09-19 14:59:43 +020024 super(TestBihash, self).setUp()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040025
26 def tearDown(self):
juraj.linkes8e26f6d2018-09-19 14:59:43 +020027 super(TestBihash, self).tearDown()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040028
29 def test_bihash_unittest(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020030 """Bihash Add/Del Test"""
Dave Barach749a89c2019-05-07 10:30:18 -040031 error = self.vapi.cli("test bihash careful 0 verbose 0")
Dave Barach8b5dc4f2018-07-23 18:00:54 -040032
33 if error:
34 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020035 self.assertNotIn("failed", error)
Dave Barach8b5dc4f2018-07-23 18:00:54 -040036
37 def test_bihash_thread(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020038 """Bihash Thread Test"""
Dave Barach8b5dc4f2018-07-23 18:00:54 -040039
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020040 error = self.vapi.cli(
41 "test bihash threads 2 nbuckets" + " 64000 careful 0 verbose 0"
42 )
Dave Barach8b5dc4f2018-07-23 18:00:54 -040043
44 if error:
45 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020046 self.assertNotIn("failed", error)
Dave Barach8b5dc4f2018-07-23 18:00:54 -040047
Dave Barach749a89c2019-05-07 10:30:18 -040048 def test_bihash_vec64(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020049 """Bihash vec64 Test"""
Dave Barach749a89c2019-05-07 10:30:18 -040050
51 error = self.vapi.cli("test bihash vec64")
52
53 if error:
54 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020055 self.assertNotIn("failed", error)
Dave Barach749a89c2019-05-07 10:30:18 -040056
Klement Sekerab23ffd72021-05-31 16:08:53 +020057 @unittest.skipUnless(config.gcov, "part of code coverage tests")
Dave Barach749a89c2019-05-07 10:30:18 -040058 def test_bihash_coverage(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020059 """Improve Code Coverage"""
Dave Barach749a89c2019-05-07 10:30:18 -040060
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020061 error = self.vapi.cli(
62 "test bihash nitems 10 ncycles 3"
63 + "search 2 careful 1 verbose 2 non-random-keys"
64 )
Dave Barach749a89c2019-05-07 10:30:18 -040065
66 if error:
67 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020068 self.assertNotIn("failed", error)
Dave Barach749a89c2019-05-07 10:30:18 -040069
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020070 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 Barach37b44542020-04-27 18:38:36 -040074 if error:
75 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020076 self.assertNotIn("failed", error)
Dave Barach37b44542020-04-27 18:38:36 -040077
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020078
79if __name__ == "__main__":
Dave Barach8b5dc4f2018-07-23 18:00:54 -040080 unittest.main(testRunner=VppTestRunner)