diff options
author | Ian Lynagh <igloo@earth.li> | 2008-11-23 16:40:14 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2008-11-23 16:40:14 +0000 |
commit | 83eafc4a45468660721d545ff8c89e3aa7ed425d (patch) | |
tree | 39d2b5a3158763953a3ff845ab3ce8aab1557136 /testsuite/driver | |
parent | 114a4e1287e9dd713d60669c893c056c4fc3d90f (diff) | |
download | haskell-83eafc4a45468660721d545ff8c89e3aa7ed425d.tar.gz |
Add a space leak test, and some infrastructure for checking space usage
Diffstat (limited to 'testsuite/driver')
-rw-r--r-- | testsuite/driver/testglobals.py | 6 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 42 |
2 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index 050a2a08b2..88774ac46b 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -176,6 +176,12 @@ class TestOptions: # extra files to clean afterward self.clean_files = [] + # which space field do we want to look at, and what bounds must + # it fall within? + self.space_field = None + self.space_min = None + self.space_max = None + # should we run this test alone, i.e. not run it in parallel with # any other threads self.alone = 0 diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index aecb32f6be..7483690d22 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -216,6 +216,16 @@ def _extra_clean( opts, v ): # ----- +def space( field, min, max ): + return lambda opts, f=field, n=min, x=max: _space(opts, f, n, x); + +def _space( opts, f, n, x ): + opts.space_field = f + opts.space_min = n + opts.space_max = x + +# ----- + def skip_if_no_ghci(opts): if not ('ghci' in config.run_ways): opts.skip = 1 @@ -447,6 +457,7 @@ def test_common_work (name, opts, func, args): '.comp.stderr.normalised', '.comp.stdout.normalised', '.interp.stderr', '.interp.stdout', '.interp.stderr.normalised', '.interp.stdout.normalised', + '.stats', '.hi', '.o', '.prof', '.exe.prof', '.hc', '_stub.h', '_stub.c', '_stub.o', '.hp', '.exe.hp', '.ps', '.aux', '.hcr'])) @@ -654,6 +665,37 @@ def compile_and_run__( name, way, extra_hc_opts, top_mod ): def compile_and_run( name, way, extra_hc_opts ): return compile_and_run__( name, way, extra_hc_opts, '') +def compile_and_run_space( name, way, extra_hc_opts ): + stats_file = name + '.stats' + opts = getTestOpts() + opts.extra_run_opts += ' +RTS -t' + stats_file + " --machine-readable -RTS" + setLocalTestOpts(opts) + + result = compile_and_run__( name, way, extra_hc_opts, '') + if result != 'pass': + return 'fail' + + f = open(stats_file) + contents = f.read() + f.close() + + m = re.search('\("' + opts.space_field + '", "([0-9]+)"\)', contents) + if m == None: + print "Failed to find space field: ", opts.space_field + return 'fail' + val = int(m.group(1)) + + if val < opts.space_min: + print 'Space usage ', val, \ + ' less than minimum allowed ', opts.space_min + return 'fail' + if val > opts.space_max: + print 'Space usage ', val, \ + ' more than maximum allowed ', opts.space_max + return 'fail' + else: + return 'pass'; + def multimod_compile_and_run( name, way, top_mod, extra_hc_opts ): return compile_and_run__( name, way, extra_hc_opts, top_mod) |