tests: make tests less make dependent
[vpp.git] / test / test_bihash.py
1 #!/usr/bin/env python3
2
3 import unittest
4
5 from config import config
6 from framework import VppTestCase, VppTestRunner
7 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
8
9
10 class TestBihash(VppTestCase):
11     """ Bihash Test Cases """
12
13     @classmethod
14     def setUpClass(cls):
15         # increase vapi timeout, to avoid spurious "test bihash ..."
16         # failures reported on aarch64 w/ test-debug
17         cls.vapi_response_timeout = 20
18         super(TestBihash, cls).setUpClass()
19
20     @classmethod
21     def tearDownClass(cls):
22         super(TestBihash, cls).tearDownClass()
23
24     def setUp(self):
25         super(TestBihash, self).setUp()
26
27     def tearDown(self):
28         super(TestBihash, self).tearDown()
29
30     def test_bihash_unittest(self):
31         """ Bihash Add/Del Test """
32         error = self.vapi.cli("test bihash careful 0 verbose 0")
33
34         if error:
35             self.logger.critical(error)
36             self.assertNotIn('failed', error)
37
38     def test_bihash_thread(self):
39         """ Bihash Thread Test """
40
41         error = self.vapi.cli("test bihash threads 2 nbuckets" +
42                               " 64000 careful 0 verbose 0")
43
44         if error:
45             self.logger.critical(error)
46             self.assertNotIn('failed', error)
47
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
57     @unittest.skipUnless(config.gcov, "part of code coverage tests")
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
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
74 if __name__ == '__main__':
75     unittest.main(testRunner=VppTestRunner)