aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-01-08 20:37:40 -0800
committerOle Trøan <otroan@employees.org>2019-02-04 15:37:38 +0000
commit895e2f850659ccc2a644d0d955c2f4313263f106 (patch)
tree8b3315ab6d78323f7372940fcde44ebdb71f8547 /test
parent2baf9422cf42e6f3ca5841bacf1a5424e6db8bea (diff)
Fix inheritance problem in test/hook.py.
Subclasses cannot modify the signature of their constructors. def __init__(self, test): - super(PollHook, self).__init__(test.logger) + super(PollHook, self).__init__(test) Change-Id: I764df8871128f9198a03fac4ec2f45528547467a Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r--test/hook.py32
-rw-r--r--test/vpp_papi_provider.py3
2 files changed, 17 insertions, 18 deletions
diff --git a/test/hook.py b/test/hook.py
index 64fc076c1a0..cddb603e46e 100644
--- a/test/hook.py
+++ b/test/hook.py
@@ -17,8 +17,9 @@ class Hook(object):
Generic hooks before/after API/CLI calls
"""
- def __init__(self, logger):
- self.logger = logger
+ def __init__(self, test):
+ self.test = test
+ self.logger = test.logger
def before_api(self, api_name, api_args):
"""
@@ -79,13 +80,12 @@ class VppDiedError(Exception):
class PollHook(Hook):
""" Hook which checks if the vpp subprocess is alive """
- def __init__(self, testcase):
- super(PollHook, self).__init__(testcase.logger)
- self.testcase = testcase
+ def __init__(self, test):
+ super(PollHook, self).__init__(test)
def on_crash(self, core_path):
self.logger.error("Core file present, debug with: gdb %s %s" %
- (self.testcase.vpp_bin, core_path))
+ (self.test.vpp_bin, core_path))
check_core_path(self.logger, core_path)
self.logger.error("Running `file %s':" % core_path)
try:
@@ -101,27 +101,27 @@ class PollHook(Hook):
Poll the vpp status and throw an exception if it's not running
:raises VppDiedError: exception if VPP is not running anymore
"""
- if self.testcase.vpp_dead:
+ if self.test.vpp_dead:
# already dead, nothing to do
return
- self.testcase.vpp.poll()
- if self.testcase.vpp.returncode is not None:
+ self.test.vpp.poll()
+ if self.test.vpp.returncode is not None:
signaldict = dict(
(k, v) for v, k in reversed(sorted(signal.__dict__.items()))
if v.startswith('SIG') and not v.startswith('SIG_'))
- if self.testcase.vpp.returncode in signaldict:
- s = signaldict[abs(self.testcase.vpp.returncode)]
+ if self.test.vpp.returncode in signaldict:
+ s = signaldict[abs(self.test.vpp.returncode)]
else:
s = "unknown"
msg = "VPP subprocess died unexpectedly with returncode %d [%s]." \
- % (self.testcase.vpp.returncode, s)
+ % (self.test.vpp.returncode, s)
self.logger.critical(msg)
- core_path = get_core_path(self.testcase.tempdir)
+ core_path = get_core_path(self.test.tempdir)
if os.path.isfile(core_path):
self.on_crash(core_path)
- self.testcase.vpp_dead = True
+ self.test.vpp_dead = True
raise VppDiedError(msg)
def before_api(self, api_name, api_args):
@@ -151,11 +151,11 @@ class PollHook(Hook):
class StepHook(PollHook):
""" Hook which requires user to press ENTER before doing any API/CLI """
- def __init__(self, testcase):
+ def __init__(self, test):
self.skip_stack = None
self.skip_num = None
self.skip_count = 0
- super(StepHook, self).__init__(testcase)
+ super(StepHook, self).__init__(test)
def skip(self):
if self.skip_stack is None:
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index d22cc7c4b49..249288b4f7f 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -1,4 +1,3 @@
-import fnmatch
import os
import time
from collections import deque
@@ -57,7 +56,7 @@ class VppPapiProvider(object):
_zero, _negative = range(2)
def __init__(self, name, shm_prefix, test_class, read_timeout):
- self.hook = Hook("vpp-papi-provider")
+ self.hook = Hook(test_class)
self.name = name
self.shm_prefix = shm_prefix
self.test_class = test_class