blob: 24639bd7a3b15707430c579e43963e3f8390ccf0 [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
Pratikshya Prasai657bdf72022-08-18 11:09:38 -04006from asfframework import VppTestCase, VppTestRunner
Dave Barach8b5dc4f2018-07-23 18:00:54 -04007from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
8
9
juraj.linkes8e26f6d2018-09-19 14:59:43 +020010class TestBihash(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020011 """Bihash Test Cases"""
Dave Barach8b5dc4f2018-07-23 18:00:54 -040012
13 @classmethod
14 def setUpClass(cls):
Dave Barachb60620b2021-02-10 07:40:05 -050015 # increase vapi timeout, to avoid spurious "test bihash ..."
16 # failures reported on aarch64 w/ test-debug
17 cls.vapi_response_timeout = 20
juraj.linkes8e26f6d2018-09-19 14:59:43 +020018 super(TestBihash, cls).setUpClass()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040019
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070020 @classmethod
21 def tearDownClass(cls):
22 super(TestBihash, cls).tearDownClass()
23
Dave Barach8b5dc4f2018-07-23 18:00:54 -040024 def setUp(self):
juraj.linkes8e26f6d2018-09-19 14:59:43 +020025 super(TestBihash, self).setUp()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040026
27 def tearDown(self):
juraj.linkes8e26f6d2018-09-19 14:59:43 +020028 super(TestBihash, self).tearDown()
Dave Barach8b5dc4f2018-07-23 18:00:54 -040029
30 def test_bihash_unittest(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020031 """Bihash Add/Del Test"""
Dave Barach749a89c2019-05-07 10:30:18 -040032 error = self.vapi.cli("test bihash careful 0 verbose 0")
Dave Barach8b5dc4f2018-07-23 18:00:54 -040033
34 if error:
35 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020036 self.assertNotIn("failed", error)
Dave Barach8b5dc4f2018-07-23 18:00:54 -040037
38 def test_bihash_thread(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 """Bihash Thread Test"""
Dave Barach8b5dc4f2018-07-23 18:00:54 -040040
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020041 error = self.vapi.cli(
42 "test bihash threads 2 nbuckets" + " 64000 careful 0 verbose 0"
43 )
Dave Barach8b5dc4f2018-07-23 18:00:54 -040044
45 if error:
46 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020047 self.assertNotIn("failed", error)
Dave Barach8b5dc4f2018-07-23 18:00:54 -040048
Dave Barach749a89c2019-05-07 10:30:18 -040049 def test_bihash_vec64(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020050 """Bihash vec64 Test"""
Dave Barach749a89c2019-05-07 10:30:18 -040051
52 error = self.vapi.cli("test bihash vec64")
53
54 if error:
55 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020056 self.assertNotIn("failed", error)
Dave Barach749a89c2019-05-07 10:30:18 -040057
Klement Sekerab23ffd72021-05-31 16:08:53 +020058 @unittest.skipUnless(config.gcov, "part of code coverage tests")
Dave Barach749a89c2019-05-07 10:30:18 -040059 def test_bihash_coverage(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020060 """Improve Code Coverage"""
Dave Barach749a89c2019-05-07 10:30:18 -040061
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020062 error = self.vapi.cli(
63 "test bihash nitems 10 ncycles 3"
64 + "search 2 careful 1 verbose 2 non-random-keys"
65 )
Dave Barach749a89c2019-05-07 10:30:18 -040066
67 if error:
68 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020069 self.assertNotIn("failed", error)
Dave Barach749a89c2019-05-07 10:30:18 -040070
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020071 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 Barach37b44542020-04-27 18:38:36 -040075 if error:
76 self.logger.critical(error)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020077 self.assertNotIn("failed", error)
Dave Barach37b44542020-04-27 18:38:36 -040078
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020079
80if __name__ == "__main__":
Dave Barach8b5dc4f2018-07-23 18:00:54 -040081 unittest.main(testRunner=VppTestRunner)