Commit a0038979 authored by Edward Z. Yang's avatar Edward Z. Yang

Add support for per-test timeout adjustment (timeout_multiplier), and tighten up #367 test.

Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
parent 48b4b88d
......@@ -255,6 +255,9 @@ class TestOptions:
# Should we redirect stdout and stderr to a single file?
self.combined_output = False
# How should the timeout be adjusted on this test?
self.timeout_multiplier = 1.0
# The default set of options
global default_testopts
default_testopts = TestOptions()
......
......@@ -14,6 +14,7 @@ import traceback
import copy
import glob
import types
import math
have_subprocess = False
try:
......@@ -218,6 +219,14 @@ def _exit_code( opts, v ):
# -----
def timeout_multiplier( val ):
return lambda opts, v=val: _timeout_multiplier(opts, v)
def _timeout_multiplier( opts, v ):
opts.timeout_multiplier = v
# -----
def extra_run_opts( val ):
return lambda opts, v=val: _extra_run_opts(opts, v);
......@@ -1176,13 +1185,13 @@ def simple_run( name, way, prog, args ):
+ stdin_comes_from \
+ redirection
if getTestOpts().cmd_wrapper != None:
cmd = getTestOpts().cmd_wrapper(cmd);
if opts.cmd_wrapper != None:
cmd = opts.cmd_wrapper(cmd);
cmd = 'cd ' + getTestOpts().testdir + ' && ' + cmd
cmd = 'cd ' + opts.testdir + ' && ' + cmd
# run the command
result = runCmdFor(name, cmd)
result = runCmdFor(name, cmd, timeout_multiplier=opts.timeout_multiplier)
exit_code = result >> 8
signal = result & 0xff
......@@ -1287,7 +1296,7 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
cmd = 'cd ' + getTestOpts().testdir + " && " + cmd
result = runCmdFor(name, cmd)
result = runCmdFor(name, cmd, timeout_multiplier=getTestOpts().timeout_multiplier)
exit_code = result >> 8
signal = result & 0xff
......@@ -1714,23 +1723,24 @@ def runCmd( cmd ):
r = os.system(cmd)
return r << 8
def runCmdFor( name, cmd ):
def runCmdFor( name, cmd, timeout_multiplier=1.0 ):
if_verbose( 1, cmd )
r = 0
if config.os == 'mingw32':
# On MinGW, we will always have timeout
assert config.timeout_prog!=''
timeout = int(math.ceil(config.timeout * timeout_multiplier))
if config.timeout_prog != '':
if config.check_files_written:
fn = name + ".strace"
r = rawSystem(["strace", "-o", fn, "-fF", "-e", "creat,open,chdir,clone,vfork",
config.timeout_prog, str(config.timeout),
config.timeout_prog, str(timeout),
cmd])
addTestFilesWritten(name, fn)
rm_no_fail(fn)
else:
r = rawSystem([config.timeout_prog, str(config.timeout), cmd])
r = rawSystem([config.timeout_prog, str(timeout), cmd])
else:
r = os.system(cmd)
return r << 8
......
......@@ -22,8 +22,8 @@ test('conc072', only_ways(['threaded2']), compile_and_run, [''])
test('conc073', normal, compile_and_run, [''])
# vector code must get inlined to become non-allocating
test('367', composes([skip_if_fast, expect_fail]), compile_and_run, ['-O2'])
test('367_letnoescape', composes([skip_if_fast, expect_fail]), compile_and_run, [''])
test('367', composes([skip_if_fast, reqlib('vector'), expect_broken(367), timeout_multiplier(0.001)]), compile_and_run, ['-O2'])
test('367_letnoescape', composes([skip_if_fast, expect_broken(367), timeout_multiplier(0.001)]), compile_and_run, [''])
test('1980', normal, compile_and_run, [''])
test('2910', normal, compile_and_run, [''])
......
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