tests: add cli_return_response to vpp_papi_provider

To improve gcov/lcov code coverage stats, it's necessary to send
incorrect debug CLI commands; to force vpp into debug CLI error paths.

cli_return_response() sends commands and returns the response object,
so test vectors can handle failures.

Type: feature

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I4fab591c9d2e30c996f016e18e4fd69b9c5bed06
This commit is contained in:
Dave Barach
2019-10-09 17:28:04 -04:00
committed by Dave Wallace
parent a6b93eac59
commit 5932ce17e1
2 changed files with 21 additions and 5 deletions

View File

@ -334,6 +334,20 @@ class VppPapiProvider(object):
self.hook.after_api(api_fn.__name__, api_args)
return reply
def cli_return_response(self, cli):
""" Execute a CLI, calling the before/after hooks appropriately.
Return the reply without examining it
:param cli: CLI to execute
:returns: response object
"""
self.hook.before_cli(cli)
cli += '\n'
r = self.papi.cli_inband(cmd=cli)
self.hook.after_cli(cli)
return r
def cli(self, cli):
""" Execute a CLI, calling the before/after hooks appropriately.
@ -341,10 +355,7 @@ class VppPapiProvider(object):
:returns: CLI output
"""
self.hook.before_cli(cli)
cli += '\n'
r = self.papi.cli_inband(cmd=cli)
self.hook.after_cli(cli)
r = self.cli_return_response(cli)
if r.retval == -156:
raise CliSyntaxError(r.reply)
if r.retval != 0: