summaryrefslogtreecommitdiffstats
path: root/test/framework.py
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2016-11-24 01:59:16 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2016-11-28 11:54:47 +0000
commit085f5c00661ef00a038d3d54be7be6dafd0a6d89 (patch)
tree649461c595f1f1e2709bc149b9d8b26a83417c54 /test/framework.py
parent475f055305cf904b1c1c0436654f2f3e1c4f3358 (diff)
make test: detect early vpp crash
If VPP process dies right at start, do a quick detection instead of being stuck in the connect timeout (60s). Change-Id: I41675181635fb81a6a7d93fbf652480a16bf78a0 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/framework.py')
-rw-r--r--test/framework.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/test/framework.py b/test/framework.py
index 1375f076dd6..315556a8833 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -177,6 +177,7 @@ class VppTestCase(unittest.TestCase):
cls.pg_streams = []
cls.packet_infos = {}
cls.verbose = 0
+ cls.vpp_dead = False
print(double_line_delim)
print(colorize(getdoc(cls).splitlines()[0], YELLOW))
print(double_line_delim)
@@ -184,13 +185,22 @@ class VppTestCase(unittest.TestCase):
# doesn't get called and we might end with a zombie vpp
try:
cls.run_vpp()
- cls.vpp_dead = False
+ cls.vpp_stdout_queue = Queue()
+ cls.vpp_stdout_reader_thread = Thread(
+ target=pump_output, args=(cls.vpp.stdout, cls.vpp_stdout_queue))
+ cls.vpp_stdout_reader_thread.start()
+ cls.vpp_stderr_queue = Queue()
+ cls.vpp_stderr_reader_thread = Thread(
+ target=pump_output, args=(cls.vpp.stderr, cls.vpp_stderr_queue))
+ cls.vpp_stderr_reader_thread.start()
cls.vapi = VppPapiProvider(cls.shm_prefix, cls.shm_prefix)
if cls.step:
- cls.vapi.register_hook(StepHook(cls))
+ hook = StepHook(cls)
else:
- cls.vapi.register_hook(PollHook(cls))
+ hook = PollHook(cls)
+ cls.vapi.register_hook(hook)
time.sleep(0.1)
+ hook.poll_vpp()
try:
cls.vapi.connect()
except:
@@ -199,18 +209,11 @@ class VppTestCase(unittest.TestCase):
"VPP-API connection failed, did you forget "
"to 'continue' VPP from within gdb?", RED))
raise
- cls.vpp_stdout_queue = Queue()
- cls.vpp_stdout_reader_thread = Thread(
- target=pump_output, args=(cls.vpp.stdout, cls.vpp_stdout_queue))
- cls.vpp_stdout_reader_thread.start()
- cls.vpp_stderr_queue = Queue()
- cls.vpp_stderr_reader_thread = Thread(
- target=pump_output, args=(cls.vpp.stderr, cls.vpp_stderr_queue))
- cls.vpp_stderr_reader_thread.start()
except:
- if hasattr(cls, 'vpp'):
- cls.vpp.terminate()
- del cls.vpp
+ try:
+ cls.quit()
+ except:
+ pass
raise
@classmethod