From 5dd6a7b29f23b89aaad4fdaba0579ca5b37d7929 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Wed, 19 Jun 2019 10:29:24 -0400 Subject: tests: if vpp is dead, specify the test name in the output 'Exception: VPP is dead when setting up the test' is more helpful with the test info. Type: test Change-Id: I6a262fdcf2ecb33aae17bef3d19745053a0bade8 Signed-off-by: Paul Vinciguerra --- test/framework.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'test/framework.py') diff --git a/test/framework.py b/test/framework.py index 00fee86e9b0..79dfe1ae866 100644 --- a/test/framework.py +++ b/test/framework.py @@ -76,15 +76,24 @@ class VppDiedError(Exception): signals_by_value = {v: k for k, v in signal.__dict__.items() if k.startswith('SIG') and not k.startswith('SIG_')} - def __init__(self, rv=None): + def __init__(self, rv=None, testcase=None, method_name=None): self.rv = rv self.signal_name = None + self.testcase = testcase + self.method_name = method_name + try: self.signal_name = VppDiedError.signals_by_value[-rv] except KeyError: pass - msg = "VPP subprocess died unexpectedly with return code: %d%s." % ( + if testcase is None and method_name is None: + in_msg = '' + else: + in_msg = 'running %s.%s ' % (testcase, method_name) + + msg = "VPP subprocess died %sunexpectedly with return code: %d%s." % ( + in_msg, self.rv, ' [%s]' % self.signal_name if self.signal_name is not None else '') @@ -672,7 +681,10 @@ class VppTestCase(unittest.TestCase): super(VppTestCase, self).setUp() self.reporter.send_keep_alive(self) if self.vpp_dead: - raise Exception("VPP is dead when setting up the test") + raise VppDiedError(self.__class__.__name__, self._testMethodName, + "VPP is dead when setting up the test " + "(%s.%s)." % (self.__class__.__name__, + self._testMethodName)) self.sleep(.1, "during setUp") self.vpp_stdout_deque.append( "--- test setUp() for %s.%s(%s) starts here ---\n" % -- cgit 1.2.3-korg