From 0b0a84c403ba5fb1473f8d34745ad2ce0dbb2d45 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Sat, 2 May 2020 10:40:33 -0400 Subject: 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 --- test/vpp_papi_provider.py | 16 ++++++++++++---- 1 file 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) -- cgit 1.2.3-korg