aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_tests.py
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2018-02-16 19:25:06 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-02-17 20:42:49 +0000
commit545be52c793512a441d2bc7c1706b5f76466055e (patch)
treed7a4ffa0b310ced1e4af28bea2f8f56cc76d0fee /test/run_tests.py
parent49bec57f2534a9d8b14e6fc9f9e15427bb42f895 (diff)
make test: detect child crash
This change causes parent process to detect child crash in seconds instead of waiting for timeout to pass. Change-Id: Ib45e86b7fc97e687d99c554be4212aaeea781dcc Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/run_tests.py')
-rw-r--r--test/run_tests.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/test/run_tests.py b/test/run_tests.py
index df6bf6cbaf4..fd8ca1f50ab 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -6,6 +6,7 @@ import os
import select
import unittest
import argparse
+import time
from multiprocessing import Process, Pipe
from framework import VppTestRunner
from debug import spawn_gdb
@@ -60,31 +61,39 @@ def run_forked(suite):
last_test = None
result = None
failed = set()
- while result is None:
+ last_heard = time.time()
+ while True:
readable = select.select([keep_alive_parent_end.fileno(),
result_parent_end.fileno(),
failed_parent_end.fileno(),
],
- [], [], test_timeout)[0]
- timeout = True
+ [], [], 1)[0]
if result_parent_end.fileno() in readable:
result = result_parent_end.recv()
- timeout = False
+ break
if keep_alive_parent_end.fileno() in readable:
while keep_alive_parent_end.poll():
last_test, last_test_vpp_binary,\
last_test_temp_dir, vpp_pid = keep_alive_parent_end.recv()
- timeout = False
+ last_heard = time.time()
if failed_parent_end.fileno() in readable:
while failed_parent_end.poll():
failed_test = failed_parent_end.recv()
failed.add(failed_test.__name__)
- timeout = False
- if timeout:
+ last_heard = time.time()
+ fail = False
+ if last_heard + test_timeout < time.time():
+ fail = True
global_logger.critical("Timeout while waiting for child test "
"runner process (last test running was "
"`%s' in `%s')!" %
(last_test, last_test_temp_dir))
+ elif not child.is_alive():
+ fail = True
+ global_logger.critical("Child process unexpectedly died (last "
+ "test running was `%s' in `%s')!" %
+ (last_test, last_test_temp_dir))
+ if fail:
failed_dir = os.getenv('VPP_TEST_FAILED_DIR')
lttd = last_test_temp_dir.split("/")[-1]
link_path = '%s%s-FAILED' % (failed_dir, lttd)
@@ -106,6 +115,7 @@ def run_forked(suite):
global_logger)
child.terminate()
result = -1
+ break
keep_alive_parent_end.close()
result_parent_end.close()
failed_parent_end.close()