2019-11-12 17:51:18 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from framework import VppTestCase, VppTestRunner, running_extended_tests
|
|
|
|
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
|
|
|
|
|
|
|
|
|
|
|
|
class TestVlib(VppTestCase):
|
|
|
|
""" Vlib Unit Test Cases """
|
|
|
|
worker_config = "workers 1"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestVlib, cls).setUpClass()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestVlib, cls).tearDownClass()
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestVlib, self).setUp()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
super(TestVlib, self).tearDown()
|
|
|
|
|
2019-12-25 09:24:58 -05:00
|
|
|
@unittest.skipUnless(running_extended_tests, "part of extended tests")
|
2019-11-12 17:51:18 -05:00
|
|
|
def test_vlib_main_unittest(self):
|
|
|
|
""" Vlib main.c Code Coverage Test """
|
|
|
|
|
|
|
|
cmds = ["loopback create",
|
|
|
|
"packet-generator new {\n"
|
|
|
|
" name vlib\n"
|
|
|
|
" limit 15\n"
|
|
|
|
" size 128-128\n"
|
|
|
|
" interface loop0\n"
|
|
|
|
" node ethernet-input\n"
|
|
|
|
" data {\n"
|
|
|
|
" IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
|
|
|
|
" ICMP: db00::1 -> db00::2\n"
|
|
|
|
" incrementing 30\n"
|
tests: fix typo in test_vlib
Trailing comma made last line of a multi-line command a new command.
Logs:
22:39:49,695 Return value: cli_inband_reply(_0=794, context=2, retval=0, reply='loop0\n')
22:39:49,695 CLI: packet-generator new {
name vlib
limit 15
size 128-128
interface loop0
node ethernet-input
data {
IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00
ICMP: db00::1 -> db00::2
incrementing 30
}
22:39:49,695 Calling cli_inband('cmd':'packet-generator new {\n name vlib\n limit 15\n size 128-128\n interface loop0\n node ethernet-input\n data {\n IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n ICMP: db00::1 -> db00::2\n incrementing 30\n }\n\n','context':3,'_vl_msg_id':792)
22:39:49,696 Return value: cli_inband_reply(_0=794, context=3, retval=0, reply='')
22:39:49,696 CLI: }
22:39:49,696 Calling cli_inband('cmd':'}\n\n','context':4,'_vl_msg_id':792)
22:39:49,697 Return value: cli_inband_reply(_0=794, context=4, retval=-1, reply="unknown inpu...
22:39:49,697 }
FAIL reply unknown input `}'
Type: fix
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Change-Id: Iaa82d432677d742e766e42383364adda5bd87665
2019-11-22 22:12:31 -05:00
|
|
|
" }\n"
|
2019-11-12 17:51:18 -05:00
|
|
|
"}\n",
|
|
|
|
"elog trace dispatch",
|
|
|
|
"event-logger stop",
|
|
|
|
"event-logger clear",
|
|
|
|
"event-logger resize 102400",
|
|
|
|
"event-logger restart",
|
|
|
|
"pcap dispatch trace on max 100 buffer-trace pg-input 15",
|
|
|
|
"set pmc instructions-per-clock",
|
|
|
|
"pa en",
|
|
|
|
"show event-log 100 all",
|
|
|
|
"event-log save",
|
|
|
|
"event-log save foo",
|
|
|
|
"pcap dispatch trace",
|
|
|
|
"pcap dispatch trace status",
|
|
|
|
"pcap dispatch trace off",
|
|
|
|
"show vlib frame-allocation",
|
|
|
|
]
|
|
|
|
|
|
|
|
for cmd in cmds:
|
|
|
|
r = self.vapi.cli_return_response(cmd)
|
|
|
|
if r.retval != 0:
|
|
|
|
if hasattr(r, 'reply'):
|
|
|
|
self.logger.info(cmd + " FAIL reply " + r.reply)
|
|
|
|
else:
|
|
|
|
self.logger.info(cmd + " FAIL retval " + str(r.retval))
|
|
|
|
|
|
|
|
def test_vlib_node_cli_unittest(self):
|
|
|
|
""" Vlib node_cli.c Code Coverage Test """
|
|
|
|
|
|
|
|
cmds = ["loopback create",
|
|
|
|
"packet-generator new {\n"
|
|
|
|
" name vlib\n"
|
|
|
|
" limit 15\n"
|
|
|
|
" size 128-128\n"
|
|
|
|
" interface loop0\n"
|
|
|
|
" node ethernet-input\n"
|
|
|
|
" data {\n"
|
|
|
|
" IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
|
|
|
|
" ICMP: db00::1 -> db00::2\n"
|
|
|
|
" incrementing 30\n"
|
tests: fix typo in test_vlib
Trailing comma made last line of a multi-line command a new command.
Logs:
22:39:49,695 Return value: cli_inband_reply(_0=794, context=2, retval=0, reply='loop0\n')
22:39:49,695 CLI: packet-generator new {
name vlib
limit 15
size 128-128
interface loop0
node ethernet-input
data {
IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00
ICMP: db00::1 -> db00::2
incrementing 30
}
22:39:49,695 Calling cli_inband('cmd':'packet-generator new {\n name vlib\n limit 15\n size 128-128\n interface loop0\n node ethernet-input\n data {\n IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n ICMP: db00::1 -> db00::2\n incrementing 30\n }\n\n','context':3,'_vl_msg_id':792)
22:39:49,696 Return value: cli_inband_reply(_0=794, context=3, retval=0, reply='')
22:39:49,696 CLI: }
22:39:49,696 Calling cli_inband('cmd':'}\n\n','context':4,'_vl_msg_id':792)
22:39:49,697 Return value: cli_inband_reply(_0=794, context=4, retval=-1, reply="unknown inpu...
22:39:49,697 }
FAIL reply unknown input `}'
Type: fix
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Change-Id: Iaa82d432677d742e766e42383364adda5bd87665
2019-11-22 22:12:31 -05:00
|
|
|
" }\n"
|
2019-11-12 17:51:18 -05:00
|
|
|
"}\n",
|
|
|
|
"show vlib graph",
|
|
|
|
"show vlib graph ethernet-input",
|
|
|
|
"show vlib graphviz",
|
|
|
|
"show vlib graphviz graphviz.dot",
|
|
|
|
"pa en",
|
|
|
|
"show runtime ethernet-input",
|
|
|
|
"show runtime brief verbose max summary",
|
|
|
|
"clear runtime",
|
|
|
|
"show node index 1",
|
|
|
|
"show node ethernet-input",
|
|
|
|
"show node pg-input",
|
|
|
|
"set node function",
|
|
|
|
"set node function no-such-node",
|
|
|
|
"set node function cdp-input default",
|
|
|
|
"set node function ethernet-input default",
|
|
|
|
"set node function ethernet-input bozo",
|
|
|
|
"set node function ethernet-input",
|
2019-12-09 10:45:47 -05:00
|
|
|
"show \t",
|
2019-11-12 17:51:18 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
for cmd in cmds:
|
|
|
|
r = self.vapi.cli_return_response(cmd)
|
|
|
|
if r.retval != 0:
|
|
|
|
if hasattr(r, 'reply'):
|
|
|
|
self.logger.info(cmd + " FAIL reply " + r.reply)
|
|
|
|
else:
|
|
|
|
self.logger.info(cmd + " FAIL retval " + str(r.retval))
|
|
|
|
|
2019-11-18 17:16:49 -05:00
|
|
|
def test_vlib_buffer_c_unittest(self):
|
|
|
|
""" Vlib buffer.c Code Coverage Test """
|
|
|
|
|
|
|
|
cmds = ["loopback create",
|
|
|
|
"packet-generator new {\n"
|
|
|
|
" name vlib\n"
|
|
|
|
" limit 15\n"
|
|
|
|
" size 128-128\n"
|
|
|
|
" interface loop0\n"
|
|
|
|
" node ethernet-input\n"
|
|
|
|
" data {\n"
|
|
|
|
" IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
|
|
|
|
" ICMP: db00::1 -> db00::2\n"
|
|
|
|
" incrementing 30\n"
|
tests: fix typo in test_vlib
Trailing comma made last line of a multi-line command a new command.
Logs:
22:39:49,695 Return value: cli_inband_reply(_0=794, context=2, retval=0, reply='loop0\n')
22:39:49,695 CLI: packet-generator new {
name vlib
limit 15
size 128-128
interface loop0
node ethernet-input
data {
IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00
ICMP: db00::1 -> db00::2
incrementing 30
}
22:39:49,695 Calling cli_inband('cmd':'packet-generator new {\n name vlib\n limit 15\n size 128-128\n interface loop0\n node ethernet-input\n data {\n IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n ICMP: db00::1 -> db00::2\n incrementing 30\n }\n\n','context':3,'_vl_msg_id':792)
22:39:49,696 Return value: cli_inband_reply(_0=794, context=3, retval=0, reply='')
22:39:49,696 CLI: }
22:39:49,696 Calling cli_inband('cmd':'}\n\n','context':4,'_vl_msg_id':792)
22:39:49,697 Return value: cli_inband_reply(_0=794, context=4, retval=-1, reply="unknown inpu...
22:39:49,697 }
FAIL reply unknown input `}'
Type: fix
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Change-Id: Iaa82d432677d742e766e42383364adda5bd87665
2019-11-22 22:12:31 -05:00
|
|
|
" }\n"
|
2019-11-18 17:16:49 -05:00
|
|
|
"}\n",
|
2019-12-09 10:45:47 -05:00
|
|
|
"elog trace",
|
|
|
|
"elog trace enable",
|
|
|
|
"elog trace api cli barrier",
|
2019-11-18 17:16:49 -05:00
|
|
|
"pa en",
|
2019-12-09 10:45:47 -05:00
|
|
|
"show interface bogus",
|
|
|
|
"elog trace disable api cli barrier",
|
|
|
|
"elog trace circuit-node ethernet-input",
|
|
|
|
"elog trace circuit-node ethernet-input disable",
|
2019-11-19 10:36:41 -05:00
|
|
|
"clear interfaces",
|
2019-11-18 17:16:49 -05:00
|
|
|
"test vlib",
|
2019-12-09 10:45:47 -05:00
|
|
|
"test vlib2",
|
|
|
|
"show memory api-segment stats-segment main-heap verbose",
|
|
|
|
"leak-check { show memory }",
|
|
|
|
"show cpu",
|
|
|
|
"memory-trace main-heap",
|
|
|
|
"memory-trace main-heap api-segment stats-segment",
|
|
|
|
"leak-check { show version }",
|
|
|
|
"show version ?",
|
|
|
|
"comment { show version }",
|
|
|
|
"uncomment { show version }",
|
|
|
|
"show memory main-heap",
|
|
|
|
"show memory bogus",
|
|
|
|
"choices",
|
|
|
|
"test heap-validate",
|
|
|
|
"memory-trace main-heap disable",
|
2019-11-18 17:16:49 -05:00
|
|
|
"show buffers",
|
2019-12-09 10:45:47 -05:00
|
|
|
"show eve",
|
|
|
|
"show help",
|
|
|
|
"show ip ",
|
2019-11-18 17:16:49 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
for cmd in cmds:
|
|
|
|
r = self.vapi.cli_return_response(cmd)
|
|
|
|
if r.retval != 0:
|
|
|
|
if hasattr(r, 'reply'):
|
|
|
|
self.logger.info(cmd + " FAIL reply " + r.reply)
|
|
|
|
else:
|
|
|
|
self.logger.info(cmd + " FAIL retval " + str(r.retval))
|
|
|
|
|
2019-11-19 10:36:41 -05:00
|
|
|
def test_vlib_format_unittest(self):
|
|
|
|
""" Vlib format.c Code Coverage Test """
|
|
|
|
|
|
|
|
cmds = ["loopback create",
|
2019-12-24 16:59:38 -05:00
|
|
|
"classify filter pcap mask l2 proto match l2 proto 0x86dd",
|
|
|
|
"classify filter pcap del",
|
2019-11-19 10:36:41 -05:00
|
|
|
"test format-vlib",
|
|
|
|
]
|
|
|
|
|
|
|
|
for cmd in cmds:
|
|
|
|
r = self.vapi.cli_return_response(cmd)
|
|
|
|
if r.retval != 0:
|
|
|
|
if hasattr(r, 'reply'):
|
|
|
|
self.logger.info(cmd + " FAIL reply " + r.reply)
|
|
|
|
else:
|
|
|
|
self.logger.info(cmd + " FAIL retval " + str(r.retval))
|
|
|
|
|
2019-11-12 17:51:18 -05:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(testRunner=VppTestRunner)
|