mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 21:07:34 -04:00
Subprocess timeout feature
Sometimes spike does not terminate when you might expect. This is a bit of a hack to get CI dailies to fail in a reasonable time.
This commit is contained in:
parent
f71b23ddf8
commit
15230d2c86
3 changed files with 20 additions and 8 deletions
|
@ -45,7 +45,8 @@ def main() -> int:
|
|||
cmd = [spike, '--log-commits', '--isa', iss_isa, '-l', args.input]
|
||||
return run_one(args.verbose,
|
||||
cmd,
|
||||
redirect_stdstreams=args.output)
|
||||
redirect_stdstreams=args.output,
|
||||
timeout_s=30) # Spike can run indefinitely in some cases
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -7,7 +7,7 @@ import sys
|
|||
|
||||
from ibex_cmd import get_sim_opts
|
||||
from sim_cmd import get_simulator_cmd
|
||||
from scripts_lib import read_test_dot_seed, subst_vars
|
||||
from scripts_lib import read_test_dot_seed, subst_vars, run_one
|
||||
from test_entry import get_test_entry
|
||||
|
||||
_CORE_IBEX = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
@ -102,7 +102,7 @@ def main() -> int:
|
|||
sim_log = os.path.join(args.out_dir, 'rtl.log')
|
||||
os.makedirs(args.out_dir, exist_ok=True)
|
||||
with open(sim_log, 'wb') as sim_fd:
|
||||
subprocess.run(test_cmd, shell=True, stdout=sim_fd, stderr=sim_fd)
|
||||
run_one(False, test_cmd, redirect_stdstreams=sim_fd, timeout_s=900, shell=True)
|
||||
|
||||
# Always return 0 (success), even if the test failed. We've successfully
|
||||
# generated a log either way.
|
||||
|
|
|
@ -29,6 +29,8 @@ TestAndSeed = Tuple[str, int]
|
|||
def run_one(verbose: bool,
|
||||
cmd: List[str],
|
||||
redirect_stdstreams: Optional[Union[str, IO]] = None,
|
||||
timeout_s: Optional[int] = None,
|
||||
shell: Optional[bool] = False,
|
||||
env: Dict[str, str] = None) -> int:
|
||||
'''Run a command, returning its return code
|
||||
|
||||
|
@ -75,11 +77,20 @@ def run_one(verbose: bool,
|
|||
# Passing close_fds=False ensures that if cmd is a call to Make then
|
||||
# we'll pass through the jobserver fds. If you don't do this, you get a
|
||||
# warning starting "warning: jobserver unavailable".
|
||||
return subprocess.run(cmd,
|
||||
stdout=stdstream_dest,
|
||||
stderr=stdstream_dest,
|
||||
close_fds=False,
|
||||
env=env).returncode
|
||||
ps = subprocess.run(cmd,
|
||||
stdout=stdstream_dest,
|
||||
stderr=stdstream_dest,
|
||||
close_fds=False,
|
||||
timeout=timeout_s,
|
||||
shell=shell,
|
||||
env=env)
|
||||
return ps.returncode
|
||||
except subprocess.CalledProcessError:
|
||||
print(ps.communicate()[0])
|
||||
return(1)
|
||||
except subprocess.TimeoutExpired:
|
||||
print("Error: Timeout[{}s]: {}".format(timeout_s, cmd))
|
||||
return(1)
|
||||
finally:
|
||||
if needs_closing:
|
||||
stdstream_dest.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue