blob: 82cf6abc42179d357eaa62dce1d8f8139fa1b7e3 [file] [log] [blame]
Dave Barachd9ca7c92019-11-12 17:51:18 -05001#!/usr/bin/env python3
2
3import unittest
4
5from framework import VppTestCase, VppTestRunner, running_extended_tests
6from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
7
8
9class TestVlib(VppTestCase):
10 """ Vlib Unit Test Cases """
11 worker_config = "workers 1"
12
13 @classmethod
14 def setUpClass(cls):
15 super(TestVlib, cls).setUpClass()
16
17 @classmethod
18 def tearDownClass(cls):
19 super(TestVlib, cls).tearDownClass()
20
21 def setUp(self):
22 super(TestVlib, self).setUp()
23
24 def tearDown(self):
25 super(TestVlib, self).tearDown()
26
Dave Barach4ed25982019-12-25 09:24:58 -050027 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Barachd9ca7c92019-11-12 17:51:18 -050028 def test_vlib_main_unittest(self):
29 """ Vlib main.c Code Coverage Test """
30
31 cmds = ["loopback create",
32 "packet-generator new {\n"
33 " name vlib\n"
34 " limit 15\n"
35 " size 128-128\n"
36 " interface loop0\n"
37 " node ethernet-input\n"
38 " data {\n"
39 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
40 " ICMP: db00::1 -> db00::2\n"
41 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -050042 " }\n"
Dave Barachd9ca7c92019-11-12 17:51:18 -050043 "}\n",
44 "elog trace dispatch",
45 "event-logger stop",
46 "event-logger clear",
47 "event-logger resize 102400",
48 "event-logger restart",
49 "pcap dispatch trace on max 100 buffer-trace pg-input 15",
50 "set pmc instructions-per-clock",
51 "pa en",
52 "show event-log 100 all",
53 "event-log save",
54 "event-log save foo",
55 "pcap dispatch trace",
56 "pcap dispatch trace status",
57 "pcap dispatch trace off",
58 "show vlib frame-allocation",
59 ]
60
61 for cmd in cmds:
62 r = self.vapi.cli_return_response(cmd)
63 if r.retval != 0:
64 if hasattr(r, 'reply'):
65 self.logger.info(cmd + " FAIL reply " + r.reply)
66 else:
67 self.logger.info(cmd + " FAIL retval " + str(r.retval))
68
69 def test_vlib_node_cli_unittest(self):
70 """ Vlib node_cli.c Code Coverage Test """
71
72 cmds = ["loopback create",
73 "packet-generator new {\n"
74 " name vlib\n"
75 " limit 15\n"
76 " size 128-128\n"
77 " interface loop0\n"
78 " node ethernet-input\n"
79 " data {\n"
80 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
81 " ICMP: db00::1 -> db00::2\n"
82 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -050083 " }\n"
Dave Barachd9ca7c92019-11-12 17:51:18 -050084 "}\n",
85 "show vlib graph",
86 "show vlib graph ethernet-input",
87 "show vlib graphviz",
88 "show vlib graphviz graphviz.dot",
89 "pa en",
90 "show runtime ethernet-input",
91 "show runtime brief verbose max summary",
92 "clear runtime",
93 "show node index 1",
94 "show node ethernet-input",
95 "show node pg-input",
96 "set node function",
97 "set node function no-such-node",
98 "set node function cdp-input default",
99 "set node function ethernet-input default",
100 "set node function ethernet-input bozo",
101 "set node function ethernet-input",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500102 "show \t",
Dave Barachd9ca7c92019-11-12 17:51:18 -0500103 ]
104
105 for cmd in cmds:
106 r = self.vapi.cli_return_response(cmd)
107 if r.retval != 0:
108 if hasattr(r, 'reply'):
109 self.logger.info(cmd + " FAIL reply " + r.reply)
110 else:
111 self.logger.info(cmd + " FAIL retval " + str(r.retval))
112
Dave Barachc17fc442019-11-18 17:16:49 -0500113 def test_vlib_buffer_c_unittest(self):
114 """ Vlib buffer.c Code Coverage Test """
115
116 cmds = ["loopback create",
117 "packet-generator new {\n"
118 " name vlib\n"
119 " limit 15\n"
120 " size 128-128\n"
121 " interface loop0\n"
122 " node ethernet-input\n"
123 " data {\n"
124 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
125 " ICMP: db00::1 -> db00::2\n"
126 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -0500127 " }\n"
Dave Barachc17fc442019-11-18 17:16:49 -0500128 "}\n",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500129 "elog trace",
130 "elog trace enable",
131 "elog trace api cli barrier",
Dave Barachc17fc442019-11-18 17:16:49 -0500132 "pa en",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500133 "show interface bogus",
134 "elog trace disable api cli barrier",
135 "elog trace circuit-node ethernet-input",
136 "elog trace circuit-node ethernet-input disable",
Dave Barache51a9bb2019-11-19 10:36:41 -0500137 "clear interfaces",
Dave Barachc17fc442019-11-18 17:16:49 -0500138 "test vlib",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500139 "test vlib2",
140 "show memory api-segment stats-segment main-heap verbose",
141 "leak-check { show memory }",
142 "show cpu",
143 "memory-trace main-heap",
144 "memory-trace main-heap api-segment stats-segment",
145 "leak-check { show version }",
146 "show version ?",
147 "comment { show version }",
148 "uncomment { show version }",
149 "show memory main-heap",
150 "show memory bogus",
151 "choices",
152 "test heap-validate",
153 "memory-trace main-heap disable",
Dave Barachc17fc442019-11-18 17:16:49 -0500154 "show buffers",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500155 "show eve",
156 "show help",
157 "show ip ",
Dave Barachc17fc442019-11-18 17:16:49 -0500158 ]
159
160 for cmd in cmds:
161 r = self.vapi.cli_return_response(cmd)
162 if r.retval != 0:
163 if hasattr(r, 'reply'):
164 self.logger.info(cmd + " FAIL reply " + r.reply)
165 else:
166 self.logger.info(cmd + " FAIL retval " + str(r.retval))
167
Dave Barache51a9bb2019-11-19 10:36:41 -0500168 def test_vlib_format_unittest(self):
169 """ Vlib format.c Code Coverage Test """
170
171 cmds = ["loopback create",
Dave Barach29c61322019-12-24 16:59:38 -0500172 "classify filter pcap mask l2 proto match l2 proto 0x86dd",
173 "classify filter pcap del",
Dave Barache51a9bb2019-11-19 10:36:41 -0500174 "test format-vlib",
175 ]
176
177 for cmd in cmds:
178 r = self.vapi.cli_return_response(cmd)
179 if r.retval != 0:
180 if hasattr(r, 'reply'):
181 self.logger.info(cmd + " FAIL reply " + r.reply)
182 else:
183 self.logger.info(cmd + " FAIL retval " + str(r.retval))
184
Dave Barachd9ca7c92019-11-12 17:51:18 -0500185if __name__ == '__main__':
186 unittest.main(testRunner=VppTestRunner)