diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2020-05-02 10:40:33 -0400 |
---|---|---|
committer | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2020-05-03 13:52:46 -0400 |
commit | 0b0a84c403ba5fb1473f8d34745ad2ce0dbb2d45 (patch) | |
tree | b55739bfdef37595ec4bf6004b1e6260bc4d528a /test | |
parent | e31820af10cfdea8baf941ee7df676db92d5b1bb (diff) |
tests: improve vpp_papi_provider exception output
saves time debugging tests by replacing 'API call' with
the actual function signature:
vpp_papi_provider.UnexpectedApiReturnValueError: API call failed, expected 0 return value instead of -2 in vxlan_add_del_tunnel_reply(_0=247, context=5052, retval=-2, sw_if_index=4294967295)
vpp_papi_provider.UnexpectedApiReturnValueError: vxlan_add_del_tunnel(is_add=0, src_address=172.16.1.1, dst_address=239.1.1.209, vni=209, sw_if_index=26, mcast_sw_if_index=1, encap_vrf_id=None, instance=None, decap_next_index=None) failed, expected 0 return value instead of -2 in vxlan_add_del_tunnel_reply(_0=247, context=5052, retval=-2, sw_if_index=4294967295)
Type: test
Change-Id: Ie3b6a5fdb4e1d427d60c51f7a7bf815af0bb3de6
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/vpp_papi_provider.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index aa95010a4ea..73544125a7c 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -115,6 +115,10 @@ defaultmapping = { } +def as_fn_signature(d): + return ", ".join(f"{k}={v}" for k, v in d.items()) + + class CliFailedCommandError(Exception): """ cli command failed.""" @@ -289,15 +293,19 @@ class VppPapiProvider(object): reply = api_fn(**api_args) if self._expect_api_retval == self._negative: if hasattr(reply, 'retval') and reply.retval >= 0: - msg = "API call passed unexpectedly: expected negative " \ + msg = "%s(%s) passed unexpectedly: expected negative " \ "return value instead of %d in %s" % \ - (reply.retval, moves.reprlib.repr(reply)) + (api_fn.__name__, as_fn_signature(api_args), + reply.retval, + moves.reprlib.repr(reply)) self.test_class.logger.info(msg) raise UnexpectedApiReturnValueError(msg) elif self._expect_api_retval == self._zero: if hasattr(reply, 'retval') and reply.retval != expected_retval: - msg = "API call failed, expected %d return value instead " \ - "of %d in %s" % (expected_retval, reply.retval, + msg = "%s(%s) failed, expected %d return value instead " \ + "of %d in %s" % (api_fn.__name__, + as_fn_signature(api_args), + expected_retval, reply.retval, repr(reply)) self.test_class.logger.info(msg) raise UnexpectedApiReturnValueError(msg) |