Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
session: cleanup application interface
[vpp.git]
/
test
/
hook.py
diff --git
a/test/hook.py
b/test/hook.py
index
64fc076
..
cddb603
100644
(file)
--- a/
test/hook.py
+++ b/
test/hook.py
@@
-17,8
+17,9
@@
class Hook(object):
Generic hooks before/after API/CLI calls
"""
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):
"""
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 """
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" %
def on_crash(self, core_path):
self.logger.error("Core file present, debug with: gdb %s %s" %
- (self.test
case
.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:
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
"""
Poll the vpp status and throw an exception if it's not running
:raises VppDiedError: exception if VPP is not running anymore
"""
- if self.test
case
.vpp_dead:
+ if self.test.vpp_dead:
# already dead, nothing to do
return
# already dead, nothing to do
return
- self.test
case
.vpp.poll()
- if self.test
case
.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_'))
signaldict = dict(
(k, v) for v, k in reversed(sorted(signal.__dict__.items()))
if v.startswith('SIG') and not v.startswith('SIG_'))
- if self.test
case
.vpp.returncode in signaldict:
- s = signaldict[abs(self.test
case
.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]." \
else:
s = "unknown"
msg = "VPP subprocess died unexpectedly with returncode %d [%s]." \
- % (self.test
case
.vpp.returncode, s)
+ % (self.test.vpp.returncode, s)
self.logger.critical(msg)
self.logger.critical(msg)
- core_path = get_core_path(self.test
case
.tempdir)
+ core_path = get_core_path(self.test.tempdir)
if os.path.isfile(core_path):
self.on_crash(core_path)
if os.path.isfile(core_path):
self.on_crash(core_path)
- self.test
case
.vpp_dead = True
+ self.test.vpp_dead = True
raise VppDiedError(msg)
def before_api(self, api_name, api_args):
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 """
class StepHook(PollHook):
""" Hook which requires user to press ENTER before doing any API/CLI """
- def __init__(self, test
case
):
+ def __init__(self, test):
self.skip_stack = None
self.skip_num = None
self.skip_count = 0
self.skip_stack = None
self.skip_num = None
self.skip_count = 0
- super(StepHook, self).__init__(test
case
)
+ super(StepHook, self).__init__(test)
def skip(self):
if self.skip_stack is None:
def skip(self):
if self.skip_stack is None: