Commit 9d80a57b authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Use a python timeout for the testsuite when we don't have a threaded RTS

parent 65b3c0bf
......@@ -11,6 +11,14 @@ endif
HS_PROG = timeout
ifeq "$(findstring thr,$(GhcRTSWays))" "thr"
boot :: $(HS_PROG)
else
boot :: python-timeout
endif
python-timeout:
cp timeout.py timeout
chmod +x timeout
include $(TOP)/mk/target.mk
#!/usr/bin/python
import os
import signal
import sys
secs = int(sys.argv[1])
cmd = sys.argv[2]
pid = os.fork()
# XXX error checking
if pid == 0:
# child
os.setpgrp()
os.execvp('/bin/sh', ['/bin/sh', '-c', cmd])
else:
# parent
def handler(signum, frame):
os.killpg(pid, signal.SIGKILL) # XXX Kill better like .hs
sys.exit(99)
old = signal.signal(signal.SIGALRM, handler)
signal.alarm(secs)
(pid2, res) = os.waitpid(pid, 0)
if (os.WIFEXITED(res)):
sys.exit(os.WEXITSTATUS(res))
else:
sys.exit(res)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment