Commit 52848b67 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-02-04 10:59:55 by simonmar]

Add a timeout to test runs, using a wrapper program (written in
Haskell, using System.Process of course!).
parent 9f2a1934
TOP = .
include $(TOP)/mk/boilerplate.mk
SUBDIRS = timeout
CLEAN_FILES += mk/wordsize.mk
all ::
......
......@@ -60,7 +60,6 @@ for opt,arg in opts:
sys.exit(1)
config.run_ways = filter(eq(arg), config.run_ways + config.other_ways)
config.compile_ways = filter(eq(arg), config.compile_ways + config.other_ways)
# -----------------------------------------------------------------------------
# The main dude
......
......@@ -66,6 +66,10 @@ class TestConfig:
# Lists of flags for each way
self.way_flags = {}
# the timeout program
self.timeout_prog = ''
self.timeout = 300
global config
config = TestConfig()
......@@ -913,11 +917,11 @@ def guess_compiler_flags():
def runCmd( cmd ):
if_verbose( 1, cmd )
return os.system( cmd )
def runCmdNoFail( cmd ):
if_verbose( 1, cmd )
return os.system( cmd )
if (config.timeout_prog == ''):
return os.system( cmd )
else:
return os.spawnv(os.P_WAIT, config.timeout_prog,
[config.timeout_prog,`config.timeout`,cmd] )
def rm_no_fail( file ):
try:
......
......@@ -76,6 +76,7 @@ RUNTEST_OPTS += \
-e config.platform=\"$(TARGETPLATFORM)\" \
-e config.wordsize=\"$(WORDSIZE)\" \
-e default_testopts.cleanup=\"$(CLEANUP)\" \
-e config.timeout_prog=\"$(TOP)/timeout/timeout\" \
$(EXTRA_RUNTEST_OPTS)
TESTS =
......
TOP = ..
include $(TOP)/mk/boilerplate.mk
HC = $(GHC_INPLACE)
MKDEPENDHS = $(GHC_INPLACE)
SRC_HC_OPTS += -threaded
HS_PROG = timeout
boot :: $(HS_PROG)
include $(TOP)/mk/target.mk
import Control.Concurrent
import System.Environment
import System.Process
import System.Exit
main = do
args <- getArgs
case args of
[secs,cmd] -> do
p <- runCommand cmd
m <- newEmptyMVar
forkIO (do threadDelay (read secs * 1000000)
putMVar m Nothing
)
forkIO (do r <- waitForProcess p
putMVar m (Just r))
r <- takeMVar m
case r of
Nothing -> do
terminateProcess p
exitWith (ExitFailure 99)
Just r -> do
exitWith r
_other -> exitWith (ExitFailure 1)
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