def check_and_handle_core(vpp_binary, tempdir, core_crash_test): if is_core_present(tempdir): if debug_core: print('VPP core detected in %s. Last test running was %s' % (tempdir, core_crash_test)) print(single_line_delim) spawn_gdb(vpp_binary, get_core_path(tempdir)) print(single_line_delim) elif compress_core: print("Compressing core-file in test directory `%s'" % tempdir) os.system("gzip %s" % get_core_path(tempdir))
def poll_vpp(self): """ 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.vpp_dead: # already dead, nothing to do return 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_')) 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]." \ % (self.test.vpp.returncode, s) self.logger.critical(msg) core_path = get_core_path(self.test.tempdir) if os.path.isfile(core_path): self.on_crash(core_path) self.test.vpp_dead = True raise VppDiedError(msg)
def check_and_handle_core(vpp_binary, tempdir, core_crash_test): if is_core_present(tempdir): print('VPP core detected in %s. Last test running was %s' % (tempdir, core_crash_test)) print(single_line_delim) spawn_gdb(vpp_binary, get_core_path(tempdir)) print(single_line_delim)
def handle_failed_suite(logger, last_test_temp_dir, vpp_pid): if last_test_temp_dir: # Need to create link in case of a timeout or core dump without failure lttd = os.path.basename(last_test_temp_dir) failed_dir = os.getenv('FAILED_DIR') link_path = '%s%s-FAILED' % (failed_dir, lttd) if not os.path.exists(link_path): os.symlink(last_test_temp_dir, link_path) logger.error("Symlink to failed testcase directory: %s -> %s" % (link_path, lttd)) # Report core existence core_path = get_core_path(last_test_temp_dir) if os.path.exists(core_path): logger.error("Core-file exists in test temporary directory: %s!" % core_path) check_core_path(logger, core_path) logger.debug("Running `file %s':" % core_path) try: info = check_output(["file", core_path]) logger.debug(info) except CalledProcessError as e: logger.error("Could not run `file' utility on core-file, " "rc=%s" % e.returncode) if vpp_pid: # Copy api post mortem api_post_mortem_path = "/tmp/api_post_mortem.%d" % vpp_pid if os.path.isfile(api_post_mortem_path): logger.error("Copying api_post_mortem.%d to %s" % (vpp_pid, last_test_temp_dir)) shutil.copy2(api_post_mortem_path, last_test_temp_dir)
def handle_failed_suite(logger, last_test_temp_dir, vpp_pid, vpp_binary): if last_test_temp_dir: # Need to create link in case of a timeout or core dump without failure lttd = os.path.basename(last_test_temp_dir) link_path = "%s%s-FAILED" % (config.failed_dir, lttd) if not os.path.exists(link_path): os.symlink(last_test_temp_dir, link_path) logger.error( "Symlink to failed testcase directory: %s -> %s" % (link_path, lttd) ) # Report core existence core_path = get_core_path(last_test_temp_dir) if os.path.exists(core_path): logger.error( "Core-file exists in test temporary directory: %s!" % core_path ) check_core_path(logger, core_path) logger.debug("Running 'file %s':" % core_path) try: info = check_output(["file", core_path]) logger.debug(info) except CalledProcessError as e: logger.error( "Subprocess returned with return code " "while running `file' utility on core-file " "returned: " "rc=%s", e.returncode, ) except OSError as e: logger.error( "Subprocess returned with OS error while " "running 'file' utility " "on core-file: " "(%s) %s", e.errno, e.strerror, ) except Exception as e: logger.exception("Unexpected error running `file' utility on core-file") logger.error(f"gdb {vpp_binary} {core_path}") if vpp_pid: # Copy api post mortem api_post_mortem_path = "/tmp/api_post_mortem.%d" % vpp_pid if os.path.isfile(api_post_mortem_path): logger.error( "Copying api_post_mortem.%d to %s" % (vpp_pid, last_test_temp_dir) ) shutil.copy2(api_post_mortem_path, last_test_temp_dir)
def poll_vpp(self): """ 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.vpp_dead: # already dead, nothing to do return self.test.vpp.poll() if self.test.vpp.returncode is not None: self.test.vpp_dead = True raise framework.VppDiedError(rv=self.test.vpp.returncode) core_path = get_core_path(self.test.tempdir) if os.path.isfile(core_path): self.on_crash(core_path)
def handle_failed_suite(logger, last_test_temp_dir, vpp_pid): if last_test_temp_dir: # Need to create link in case of a timeout or core dump without failure lttd = os.path.basename(last_test_temp_dir) failed_dir = os.getenv('FAILED_DIR') link_path = '%s%s-FAILED' % (failed_dir, lttd) if not os.path.exists(link_path): os.symlink(last_test_temp_dir, link_path) logger.error("Symlink to failed testcase directory: %s -> %s" % (link_path, lttd)) # Report core existence core_path = get_core_path(last_test_temp_dir) if os.path.exists(core_path): logger.error( "Core-file exists in test temporary directory: %s!" % core_path) check_core_path(logger, core_path) logger.debug("Running 'file %s':" % core_path) try: info = check_output(["file", core_path]) logger.debug(info) except CalledProcessError as e: logger.error("Subprocess returned with return code " "while running `file' utility on core-file " "returned: " "rc=%s", e.returncode) except OSError as e: logger.error("Subprocess returned with OS error while " "running 'file' utility " "on core-file: " "(%s) %s", e.errno, e.strerror) except Exception as e: logger.exception("Unexpected error running `file' utility " "on core-file") if vpp_pid: # Copy api post mortem api_post_mortem_path = "/tmp/api_post_mortem.%d" % vpp_pid if os.path.isfile(api_post_mortem_path): logger.error("Copying api_post_mortem.%d to %s" % (vpp_pid, last_test_temp_dir)) shutil.copy2(api_post_mortem_path, last_test_temp_dir)