- wrapped_testcase_suite.core_detected_at = \
- time.time()
- elif wrapped_testcase_suite.core_detected_at + \
- core_timeout < time.time():
- if not os.path.isfile(
- "%s/_core_handled" %
- wrapped_testcase_suite.
- last_test_temp_dir):
- wrapped_testcase_suite.logger.critical(
- "Child python process unresponsive and "
- "core-file exists in test temporary "
- "directory!")
- wrapped_testcase_suite.fail = True
-
- if wrapped_testcase_suite.fail and not \
- wrapped_testcase_suite.fail_addressed:
- failed_dir = os.getenv('VPP_TEST_FAILED_DIR')
- lttd = os.path.basename(
- wrapped_testcase_suite.last_test_temp_dir)
- link_path = '%s%s-FAILED' % (failed_dir, lttd)
- wrapped_testcase_suite.logger.error(
- "Creating a link to the failed test: %s -> %s" %
- (link_path, lttd))
- if not os.path.exists(link_path):
- os.symlink(wrapped_testcase_suite.last_test_temp_dir,
- link_path)
- api_post_mortem_path = "/tmp/api_post_mortem.%d" % \
- wrapped_testcase_suite.vpp_pid
- if os.path.isfile(api_post_mortem_path):
- wrapped_testcase_suite.logger.error(
- "Copying api_post_mortem.%d to %s" %
- (wrapped_testcase_suite.vpp_pid,
- wrapped_testcase_suite.last_test_temp_dir))
- shutil.copy2(api_post_mortem_path,
- wrapped_testcase_suite.last_test_temp_dir)
- if wrapped_testcase_suite.last_test_temp_dir and \
- wrapped_testcase_suite.last_test_vpp_binary:
- core_path = "%s/core" % \
- wrapped_testcase_suite.last_test_temp_dir
- if os.path.isfile(core_path):
- wrapped_testcase_suite.logger.error(
- "Core-file exists in test temporary directory: %s!"
- % core_path)
- check_core_path(wrapped_testcase_suite.logger,
- core_path)
- wrapped_testcase_suite.logger.debug(
- "Running `file %s':" % core_path)
- try:
- info = check_output(["file", core_path])
- wrapped_testcase_suite.logger.debug(info)
- except CalledProcessError as e:
- wrapped_testcase_suite.logger.error(
- "Could not run `file' utility on core-file, "
- "rc=%s" % e.returncode)
- pass
- if debug_core:
- spawn_gdb(
- wrapped_testcase_suite.last_test_vpp_binary,
- core_path, wrapped_testcase_suite.logger)
- os.kill(wrapped_testcase_suite.child.pid, signal.SIGINT)
- try:
- # terminating the child process tends to leave orphan
- # VPP process around
- os.kill(wrapped_testcase_suite.vpp_pid, signal.SIGTERM)
- except OSError:
- # already dead
- pass
- wrapped_testcase_suite.fail_addressed = True
-
- for finished_testcase in finished_testcase_suites:
- finished_testcase.child.join()
- finished_testcase.close_pipes()
- wrapped_testcase_suites.remove(finished_testcase)
- finished_unread_testcases.add(finished_testcase)
- finished_testcase.stdouterr_queue.put(None)
- if len(testcases) > 0:
- new_testcase = TestCaseWrapper(testcases.pop(0), manager)
- wrapped_testcase_suites.add(new_testcase)
- unread_testcases.add(new_testcase)
-
- read_from_testcases.clear()
- stdouterr_thread.join(test_timeout)
- manager.shutdown()
+ wrapped_testcase_suite.core_detected_at = time.time()
+ elif (
+ wrapped_testcase_suite.core_detected_at + core_timeout
+ < time.time()
+ ):
+ wrapped_testcase_suite.logger.critical(
+ "Child test runner process unresponsive and "
+ "core-file exists in test temporary directory "
+ "(last test running was `%s' in `%s')!"
+ % (
+ wrapped_testcase_suite.last_test,
+ wrapped_testcase_suite.last_test_temp_dir,
+ )
+ )
+ fail = True
+
+ if fail:
+ wrapped_testcase_suite.child.terminate()
+ try:
+ # terminating the child process tends to leave orphan
+ # VPP process around
+ if wrapped_testcase_suite.vpp_pid:
+ os.kill(wrapped_testcase_suite.vpp_pid, signal.SIGTERM)
+ except OSError:
+ # already dead
+ pass
+ wrapped_testcase_suite.result.crashed = True
+ wrapped_testcase_suite.result.process_result(
+ wrapped_testcase_suite.last_test_id, ERROR
+ )
+ stop_run = (
+ process_finished_testsuite(
+ wrapped_testcase_suite,
+ finished_testcase_suites,
+ failed_wrapped_testcases,
+ results,
+ )
+ or stop_run
+ )
+
+ for finished_testcase in finished_testcase_suites:
+ # Somewhat surprisingly, the join below may
+ # timeout, even if client signaled that
+ # it finished - so we note it just in case.
+ join_start = time.time()
+ finished_testcase.child.join(test_finished_join_timeout)
+ join_end = time.time()
+ if join_end - join_start >= test_finished_join_timeout:
+ finished_testcase.logger.error(
+ "Timeout joining finished test: %s (pid %d)"
+ % (finished_testcase.last_test, finished_testcase.child.pid)
+ )
+ finished_testcase.close_pipes()
+ wrapped_testcase_suites.remove(finished_testcase)
+ finished_unread_testcases.add(finished_testcase)
+ finished_testcase.stdouterr_queue.put(None)
+ on_suite_finish(finished_testcase)
+ if stop_run:
+ while testcase_suites:
+ results.append(TestResult(testcase_suites.pop(0)))
+ elif testcase_suites:
+ a_suite = testcase_suites.pop(0)
+ while a_suite and a_suite.is_tagged_run_solo:
+ solo_testcase_suites.append(a_suite)
+ if testcase_suites:
+ a_suite = testcase_suites.pop(0)
+ else:
+ a_suite = None
+ if a_suite and can_run_suite(a_suite):
+ run_suite(a_suite)
+ if solo_testcase_suites and tests_running == 0:
+ a_suite = solo_testcase_suites.pop(0)
+ run_suite(a_suite)
+ time.sleep(0.1)
+ except Exception:
+ for wrapped_testcase_suite in wrapped_testcase_suites:
+ wrapped_testcase_suite.child.terminate()
+ wrapped_testcase_suite.stdouterr_queue.put(None)
+ raise
+ finally:
+ read_from_testcases.clear()
+ stdouterr_thread.join(config.timeout)
+ manager.shutdown()
+
+ handle_cores(failed_wrapped_testcases)