Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add a feature arc consistency check
[vpp.git]
/
test
/
framework.py
diff --git
a/test/framework.py
b/test/framework.py
index
3201e63
..
ca15202
100644
(file)
--- a/
test/framework.py
+++ b/
test/framework.py
@@
-151,6
+151,7
@@
class KeepAliveReporter(object):
def __init__(self):
self.__dict__ = self._shared_state
def __init__(self):
self.__dict__ = self._shared_state
+ self._pipe = None
@property
def pipe(self):
@property
def pipe(self):
@@
-158,7
+159,7
@@
class KeepAliveReporter(object):
@pipe.setter
def pipe(self, pipe):
@pipe.setter
def pipe(self, pipe):
- if
hasattr(self, '_pipe')
:
+ if
self._pipe is not None
:
raise Exception("Internal error - pipe should only be set once.")
self._pipe = pipe
raise Exception("Internal error - pipe should only be set once.")
self._pipe = pipe
@@
-218,8
+219,8
@@
class VppTestCase(unittest.TestCase):
else:
raise Exception("Unrecognized DEBUG option: '%s'" % d)
else:
raise Exception("Unrecognized DEBUG option: '%s'" % d)
- @
class
method
- def get_least_used_cpu(
self
):
+ @
static
method
+ def get_least_used_cpu():
cpu_usage_list = [set(range(psutil.cpu_count()))]
vpp_processes = [p for p in psutil.process_iter(attrs=['pid', 'name'])
if 'vpp_main' == p.info['name']]
cpu_usage_list = [set(range(psutil.cpu_count()))]
vpp_processes = [p for p in psutil.process_iter(attrs=['pid', 'name'])
if 'vpp_main' == p.info['name']]
@@
-247,7
+248,7
@@
class VppTestCase(unittest.TestCase):
return random.choice(tuple(min_usage_set))
return random.choice(tuple(min_usage_set))
- @
static
method
+ @
class
method
def print_header(cls):
if not hasattr(cls, '_header_printed'):
print(double_line_delim)
def print_header(cls):
if not hasattr(cls, '_header_printed'):
print(double_line_delim)
@@
-347,7
+348,7
@@
class VppTestCase(unittest.TestCase):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
bufsize=1)
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
bufsize=1)
- except
Exception
as e:
+ except
subprocess.CalledProcessError
as e:
cls.logger.critical("Couldn't start vpp: %s" % e)
raise
cls.logger.critical("Couldn't start vpp: %s" % e)
raise
@@
-356,9
+357,15
@@
class VppTestCase(unittest.TestCase):
@classmethod
def wait_for_stats_socket(cls):
deadline = time.time() + 3
@classmethod
def wait_for_stats_socket(cls):
deadline = time.time() + 3
- while time.time() < deadline or cls.debug_gdb or cls.debug_gdbserver:
+ ok = False
+ while time.time() < deadline or \
+ cls.debug_gdb or cls.debug_gdbserver:
if os.path.exists(cls.stats_sock):
if os.path.exists(cls.stats_sock):
+ ok = True
break
break
+ time.sleep(0.8)
+ if not ok:
+ cls.logger.critical("Couldn't stat : {}".format(cls.stats_sock))
@classmethod
def setUpClass(cls):
@classmethod
def setUpClass(cls):
@@
-368,10
+375,11
@@
class VppTestCase(unittest.TestCase):
"""
gc.collect() # run garbage collection first
random.seed()
"""
gc.collect() # run garbage collection first
random.seed()
- cls.print_header(
cls
)
+ cls.print_header()
cls.logger = get_logger(cls.__name__)
if hasattr(cls, 'parallel_handler'):
cls.logger.addHandler(cls.parallel_handler)
cls.logger = get_logger(cls.__name__)
if hasattr(cls, 'parallel_handler'):
cls.logger.addHandler(cls.parallel_handler)
+ cls.logger.propagate = False
cls.tempdir = tempfile.mkdtemp(
prefix='vpp-unittest-%s-' % cls.__name__)
cls.stats_sock = "%s/stats.sock" % cls.tempdir
cls.tempdir = tempfile.mkdtemp(
prefix='vpp-unittest-%s-' % cls.__name__)
cls.stats_sock = "%s/stats.sock" % cls.tempdir
@@
-1177,7
+1185,7
@@
class VppTestResult(unittest.TestResult):
:param test:
"""
:param test:
"""
- test.print_header(
test.__class__
)
+ test.print_header()
unittest.TestResult.startTest(self, test)
if self.verbosity > 0:
unittest.TestResult.startTest(self, test)
if self.verbosity > 0:
@@
-1247,8
+1255,7
@@
class VppTestRunner(unittest.TextTestRunner):
super(VppTestRunner, self).__init__(sys.stdout, descriptions,
verbosity, failfast, buffer,
resultclass)
super(VppTestRunner, self).__init__(sys.stdout, descriptions,
verbosity, failfast, buffer,
resultclass)
- reporter = KeepAliveReporter()
- reporter.pipe = keep_alive_pipe
+ KeepAliveReporter.pipe = keep_alive_pipe
VppTestResult.test_framework_result_pipe = result_pipe
VppTestResult.test_framework_result_pipe = result_pipe