blob: eedfb2fff8940907779ce45e15890dcf7b4fde73 [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
27 # @unittest.skipUnless(running_extended_tests, "part of extended tests")
28
29 def test_vlib_main_unittest(self):
30 """ Vlib main.c Code Coverage Test """
31
32 cmds = ["loopback create",
33 "packet-generator new {\n"
34 " name vlib\n"
35 " limit 15\n"
36 " size 128-128\n"
37 " interface loop0\n"
38 " node ethernet-input\n"
39 " data {\n"
40 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
41 " ICMP: db00::1 -> db00::2\n"
42 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -050043 " }\n"
Dave Barachd9ca7c92019-11-12 17:51:18 -050044 "}\n",
45 "elog trace dispatch",
46 "event-logger stop",
47 "event-logger clear",
48 "event-logger resize 102400",
49 "event-logger restart",
50 "pcap dispatch trace on max 100 buffer-trace pg-input 15",
51 "set pmc instructions-per-clock",
52 "pa en",
53 "show event-log 100 all",
54 "event-log save",
55 "event-log save foo",
56 "pcap dispatch trace",
57 "pcap dispatch trace status",
58 "pcap dispatch trace off",
59 "show vlib frame-allocation",
60 ]
61
62 for cmd in cmds:
63 r = self.vapi.cli_return_response(cmd)
64 if r.retval != 0:
65 if hasattr(r, 'reply'):
66 self.logger.info(cmd + " FAIL reply " + r.reply)
67 else:
68 self.logger.info(cmd + " FAIL retval " + str(r.retval))
69
70 def test_vlib_node_cli_unittest(self):
71 """ Vlib node_cli.c Code Coverage Test """
72
73 cmds = ["loopback create",
74 "packet-generator new {\n"
75 " name vlib\n"
76 " limit 15\n"
77 " size 128-128\n"
78 " interface loop0\n"
79 " node ethernet-input\n"
80 " data {\n"
81 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
82 " ICMP: db00::1 -> db00::2\n"
83 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -050084 " }\n"
Dave Barachd9ca7c92019-11-12 17:51:18 -050085 "}\n",
86 "show vlib graph",
87 "show vlib graph ethernet-input",
88 "show vlib graphviz",
89 "show vlib graphviz graphviz.dot",
90 "pa en",
91 "show runtime ethernet-input",
92 "show runtime brief verbose max summary",
93 "clear runtime",
94 "show node index 1",
95 "show node ethernet-input",
96 "show node pg-input",
97 "set node function",
98 "set node function no-such-node",
99 "set node function cdp-input default",
100 "set node function ethernet-input default",
101 "set node function ethernet-input bozo",
102 "set node function ethernet-input",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500103 "show \t",
Dave Barachd9ca7c92019-11-12 17:51:18 -0500104 ]
105
106 for cmd in cmds:
107 r = self.vapi.cli_return_response(cmd)
108 if r.retval != 0:
109 if hasattr(r, 'reply'):
110 self.logger.info(cmd + " FAIL reply " + r.reply)
111 else:
112 self.logger.info(cmd + " FAIL retval " + str(r.retval))
113
Dave Barachc17fc442019-11-18 17:16:49 -0500114 def test_vlib_buffer_c_unittest(self):
115 """ Vlib buffer.c Code Coverage Test """
116
117 cmds = ["loopback create",
118 "packet-generator new {\n"
119 " name vlib\n"
120 " limit 15\n"
121 " size 128-128\n"
122 " interface loop0\n"
123 " node ethernet-input\n"
124 " data {\n"
125 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
126 " ICMP: db00::1 -> db00::2\n"
127 " incrementing 30\n"
Paul Vinciguerra41a817a2019-11-22 22:12:31 -0500128 " }\n"
Dave Barachc17fc442019-11-18 17:16:49 -0500129 "}\n",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500130 "elog trace",
131 "elog trace enable",
132 "elog trace api cli barrier",
Dave Barachc17fc442019-11-18 17:16:49 -0500133 "pa en",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500134 "show interface bogus",
135 "elog trace disable api cli barrier",
136 "elog trace circuit-node ethernet-input",
137 "elog trace circuit-node ethernet-input disable",
Dave Barache51a9bb2019-11-19 10:36:41 -0500138 "clear interfaces",
Dave Barachc17fc442019-11-18 17:16:49 -0500139 "test vlib",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500140 "test vlib2",
141 "show memory api-segment stats-segment main-heap verbose",
142 "leak-check { show memory }",
143 "show cpu",
144 "memory-trace main-heap",
145 "memory-trace main-heap api-segment stats-segment",
146 "leak-check { show version }",
147 "show version ?",
148 "comment { show version }",
149 "uncomment { show version }",
150 "show memory main-heap",
151 "show memory bogus",
152 "choices",
153 "test heap-validate",
154 "memory-trace main-heap disable",
Dave Barachc17fc442019-11-18 17:16:49 -0500155 "show buffers",
Dave Barach6b3f25c2019-12-09 10:45:47 -0500156 "show eve",
157 "show help",
158 "show ip ",
Dave Barachc17fc442019-11-18 17:16:49 -0500159 ]
160
161 for cmd in cmds:
162 r = self.vapi.cli_return_response(cmd)
163 if r.retval != 0:
164 if hasattr(r, 'reply'):
165 self.logger.info(cmd + " FAIL reply " + r.reply)
166 else:
167 self.logger.info(cmd + " FAIL retval " + str(r.retval))
168
Dave Barache51a9bb2019-11-19 10:36:41 -0500169 def test_vlib_format_unittest(self):
170 """ Vlib format.c Code Coverage Test """
171
172 cmds = ["loopback create",
173 "classify filter pcap mask l2 proto ipv6 match l2 proto 86dd",
174 "classify filter del",
175 "test format-vlib",
176 ]
177
178 for cmd in cmds:
179 r = self.vapi.cli_return_response(cmd)
180 if r.retval != 0:
181 if hasattr(r, 'reply'):
182 self.logger.info(cmd + " FAIL reply " + r.reply)
183 else:
184 self.logger.info(cmd + " FAIL retval " + str(r.retval))
185
Dave Barachd9ca7c92019-11-12 17:51:18 -0500186if __name__ == '__main__':
187 unittest.main(testRunner=VppTestRunner)