Skip to content

Instantly share code, notes, and snippets.

@olofk
Created November 21, 2016 22:15
Show Gist options
  • Select an option

  • Save olofk/76b0b04181a7edd002a7529cf97ea325 to your computer and use it in GitHub Desktop.

Select an option

Save olofk/76b0b04181a7edd002a7529cf97ea325 to your computer and use it in GitHub Desktop.
import os
import signal
import subprocess
import time
subprocess.call(['fusesoc', 'sim', '--sim=verilator', '--build-only', 'mor1kx-generic'])
apps = [
'or1k-alignillegalinsn',
'or1k-backtoback_jmp',
'or1k-basic',
'or1k-cmov',
'or1k-cy',
'or1k-dsx',
'or1k-dsxinsn',
'or1k-ext',
'or1k-ffl1',
'or1k-icache',
'or1k-illegalinsn',
'or1k-illegalinsndelayslot',
'or1k-insnfetchalign',
'or1k-insnfetcherror',
'or1k-intloop',
'or1k-intmulticycle',
'or1k-intsyscall',
'or1k-inttickloop',
'or1k-jmp',
'or1k-jr',
'or1k-lsu',
'or1k-lsualign',
'or1k-lsualigndelayslot',
'or1k-lsuerror',
'or1k-lsuerrordelayslot',
'or1k-lwjr',
'or1k-msync',
'or1k-mul-basic',
'or1k-ov',
'or1k-regjmp',
'or1k-rfe',
'or1k-sf',
'or1k-sfbf',
'or1k-shiftopts',
'or1k-shortbranch',
'or1k-shortjump',
'or1k-systemcall',
'or1k-tickloop',
'or1k-tickrfforward',
'or1k-ticksyscall',
'or1k-timer',
'or1k-trap',
'or1k-trapdelayslot'
]
procs = {}
basepath = '/home/olof/code/or1k/or1k-tests/native/build/or1k'
run_cmd = ['fusesoc', 'sim', '--sim=verilator', '--keep', 'mor1kx-generic', '--elf-load']
for app in apps:
procs[app] = subprocess.Popen(run_cmd + [os.path.join(basepath, app)],
stdout=open(app+'.stdout','w'),
stderr=open(app+'.stderr','w'),
preexec_fn=os.setsid)
print("launching {} (PID {})".format(app, procs[app].pid))
time.sleep(10)
for app, proc in procs.items():
returncode = proc.poll()
if returncode is None:
print("Killing {}".format(app))
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
else:
print("{} exited with return code {}".format(app, returncode))
@rjfnobre

Copy link
Copy Markdown

Doesn't this only kill the process executing 'fusesoc' but not the subprocess executing Verilator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment