Commit 772a8047 authored by ian@well-typed.com's avatar ian@well-typed.com

Eliminate *_num_field

We now use *_range_field everywhere instead
parent a4b5be7e
......@@ -15,7 +15,7 @@ import traceback
import copy
import glob
import types
import math
from math import ceil, trunc
have_subprocess = False
try:
......@@ -260,24 +260,6 @@ def _extra_clean( opts, v ):
# -----
def stats_num_field( field, min, max ):
return lambda opts, f=field, x=min, y=max: _stats_num_field(opts, f, x, y);
def _stats_num_field( opts, f, x, y ):
# copy the dictionary, as the config gets shared between all tests
opts.stats_num_fields = opts.stats_num_fields.copy()
opts.stats_num_fields[f] = (x, y)
def compiler_stats_num_field( field, min, max ):
return lambda opts, f=field, x=min, y=max: _compiler_stats_num_field(opts, f, x, y);
def _compiler_stats_num_field( opts, f, x, y ):
# copy the dictionary, as the config gets shared between all tests
opts.compiler_stats_num_fields = opts.compiler_stats_num_fields.copy()
opts.compiler_stats_num_fields[f] = (x, y)
# -----
def stats_range_field( field, min, max ):
return lambda opts, f=field, x=min, y=max: _stats_range_field(opts, f, x, y);
......@@ -1121,15 +1103,14 @@ def multi_compile_and_run( name, way, top_mod, extra_mods, extra_hc_opts ):
def stats( name, way, stats_file ):
opts = getTestOpts()
return checkStats(stats_file, opts.stats_range_fields
, opts.stats_num_fields)
return checkStats(stats_file, opts.stats_range_fields)
# -----------------------------------------------------------------------------
# Check -t stats info
def checkStats(stats_file, range_fields, num_fields):
def checkStats(stats_file, range_fields):
result = passed()
if len(num_fields) + len(range_fields) > 0:
if len(range_fields) > 0:
f = open(in_testdir(stats_file))
contents = f.read()
f.close()
......@@ -1141,8 +1122,8 @@ def checkStats(stats_file, range_fields, num_fields):
result = failBecause('no such stats field')
val = int(m.group(1))
min = expected * ((100 - float(dev))/100);
max = expected * ((100 + float(dev))/100);
min = trunc( expected * ((100 - float(dev))/100));
max = trunc(0.5 + ceil(expected * ((100 + float(dev))/100)));
if val < min:
print field, val, 'is more than ' + repr(dev) + '%'
......@@ -1154,23 +1135,6 @@ def checkStats(stats_file, range_fields, num_fields):
print field, val, 'is more than ' + repr(dev) + '% greater than the expected value,', expected, max
result = failBecause('stat not good enough')
# ToDo: remove all uses of this, and delete it
for (field, (min, max)) in num_fields.items():
m = re.search('\("' + field + '", "([0-9]+)"\)', contents)
if m == None:
print 'Failed to find field: ', field
result = failBecause('no such stats field')
val = int(m.group(1))
if val < min:
print field, val, 'is less than minimum allowed', min
print 'If this is because you have improved GHC, please'
print 'update the test so that GHC doesn\'t regress again'
result = failBecause('stat too good')
if val > max:
print field, val, 'is more than maximum allowed', max
result = failBecause('stat not good enough')
return result
# -----------------------------------------------------------------------------
......@@ -1221,7 +1185,7 @@ def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf,
to_do = '-c' # just compile
stats_file = name + '.comp.stats'
if len(opts.compiler_stats_num_fields) + len(opts.compiler_stats_range_fields) > 0:
if len(opts.compiler_stats_range_fields) > 0:
extra_hc_opts += ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
# Required by GHC 7.3+, harmless for earlier versions:
......@@ -1260,8 +1224,7 @@ def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link, addsuf,
# ToDo: if the sub-shell was killed by ^C, then exit
statsResult = checkStats(stats_file, opts.compiler_stats_range_fields
, opts.compiler_stats_num_fields)
statsResult = checkStats(stats_file, opts.compiler_stats_range_fields)
if badResult(statsResult):
return statsResult
......@@ -1307,7 +1270,7 @@ def simple_run( name, way, prog, args ):
my_rts_flags = rts_flags(way)
stats_file = name + '.stats'
if len(opts.stats_num_fields) + len(opts.stats_range_fields) > 0:
if len(opts.stats_range_fields) > 0:
args += ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
if opts.no_stdin:
......@@ -1361,8 +1324,7 @@ def simple_run( name, way, prog, args ):
if check_prof and not check_prof_ok(name):
return failBecause('bad profile')
return checkStats(stats_file, opts.stats_range_fields
, opts.stats_num_fields)
return checkStats(stats_file, opts.stats_range_fields)
def rts_flags(way):
if (way == ''):
......@@ -1910,7 +1872,7 @@ def runCmdFor( name, cmd, timeout_multiplier=1.0 ):
if config.os == 'mingw32':
# On MinGW, we will always have timeout
assert config.timeout_prog!=''
timeout = int(math.ceil(config.timeout * timeout_multiplier))
timeout = int(ceil(config.timeout * timeout_multiplier))
if config.timeout_prog != '':
if config.check_files_written:
......
......@@ -7,21 +7,18 @@ setTestOpts(no_lint)
test('T1969',
[if_wordsize(32,
compiler_stats_num_field('peak_megabytes_allocated', 13,
19)),
compiler_stats_range_field('peak_megabytes_allocated', 18, 1)),
# expected value: 14 (x86/Windows 17/05/10)
# 15 (x86/OS X)
# 19 (x86/OS X)
if_wordsize(64,
compiler_stats_num_field('peak_megabytes_allocated', 22,
28)),
compiler_stats_range_field('peak_megabytes_allocated', 25, 1)),
# expected value: 28 (amd64/Linux)
# expected value: 34 (amd64/Linux)
# 2012-09-20 23 (amd64/Linux)
# 2012-10-03 25 (amd64/Linux if .hi exists)
if_wordsize(32,
compiler_stats_num_field('max_bytes_used', 4000000,
7000000)),
compiler_stats_range_field('max_bytes_used', 6149572, 5)),
# expected value: 6707308 (x86/OS X)
# 5717704 (x86/Windows 17/05/10)
# 6149572 (x86/Linux, 31/12/09)
......@@ -81,10 +78,9 @@ else:
test('T3294',
[if_wordsize(32,
compiler_stats_num_field('max_bytes_used', 12000000,
20000000)),
compiler_stats_range_field('max_bytes_used', 17725476, 5)),
# expected value: 17725476 (x86/OS X)
# 14593500 (Windows)
# 14593500 (Windows)
if_wordsize(64,
compiler_stats_range_field('max_bytes_used', 44894544, 15)),
# prev: 25753192 (amd64/Linux)
......@@ -122,7 +118,7 @@ test('T4801',
# expected value: 58 (amd64/OS X):
if_platform('x86_64-apple-darwin',
compiler_stats_num_field('peak_megabytes_allocated', 56, 60)),
compiler_stats_range_field('peak_megabytes_allocated', 58, 1)),
# expected value: 228286660 (x86/OS X)
if_wordsize(32,
compiler_stats_range_field('bytes allocated', 185669232, 10)),
......@@ -135,14 +131,12 @@ test('T4801',
# expected value: 510938976 (amd64/OS X):
if_platform('x86_64-apple-darwin',
compiler_stats_num_field('bytes allocated', 490000000,
530000000)),
compiler_stats_range_field('bytes allocated', 510938976, 5)),
if_wordsize(32,
compiler_stats_range_field('max_bytes_used', 9651948, 5)),
# expected value: x86/OS X: 9651948
compiler_stats_num_field('max_bytes_used', 8000000,
12000000)),
# expected value: 10290952 (windows)
# expected value: 10290952 (windows)
if_wordsize(64,
compiler_stats_range_field('max_bytes_used', 21657520, 15)),
# prev: 20486256 (amd64/OS X)
......@@ -151,8 +145,7 @@ test('T4801',
# 19/10/2012: 18619912 (-fPIC turned off)
# 24/12/2012: 21657520 (perhaps gc sampling time wibbles?)
if_platform('x86_64-apple-darwin',
compiler_stats_num_field('max_bytes_used', 20000000,
23000000)),
compiler_stats_range_field('max_bytes_used', 21657520, 5)),
only_ways(['normal']),
extra_hc_opts('-static')
],
......@@ -163,11 +156,11 @@ test('T3064',
[# expect_broken( 3064 ),
# expected value: 14 (x86/Linux 28-06-2012):
if_wordsize(32,
compiler_stats_range_field('peak_megabytes_allocated', 14, 30)),
compiler_stats_range_field('peak_megabytes_allocated', 14, 1)),
# expected value: 18 (amd64/Linux):
if_wordsize(64,
compiler_stats_num_field('peak_megabytes_allocated', 20, 28)),
compiler_stats_range_field('peak_megabytes_allocated', 24, 1)),
# expected value: 18 (amd64/Linux):
# expected value: 56380288 (x86/Linux) (28/6/2011)
# 111189536 (x86/Windows) (30/10/12)
......@@ -177,8 +170,7 @@ test('T3064',
# expected value: 73259544 (amd64/Linux) (28/6/2011):
if_wordsize(64,
compiler_stats_num_field('bytes allocated', 200000000,
280000000)),
compiler_stats_range_field('bytes allocated', 240000000, 5)),
# expected value: 2247016 (x86/Linux) (28/6/2011):
if_wordsize(32,
......@@ -186,8 +178,7 @@ test('T3064',
# expected value: 4032024 (amd64/Linux, intree) (28/6/2011):
if_wordsize(64,
compiler_stats_num_field('max_bytes_used', 8000000,
14000000)),
compiler_stats_range_field('max_bytes_used', 11000000, 5)),
only_ways(['normal'])
],
compile,
......@@ -221,8 +212,7 @@ test('T5631',
compiler_stats_range_field('bytes allocated', 392904228, 10)),
# expected value: 774,595,008 (amd64/Linux):
if_wordsize(64,
compiler_stats_num_field('bytes allocated', 600000000,
900000000)),
compiler_stats_range_field('bytes allocated', 774595008, 5)),
only_ways(['normal'])
],
compile,
......@@ -234,8 +224,7 @@ test('parsing001',
compiler_stats_range_field('bytes allocated', 274000576, 10)),
# expected value: 587079016 (amd64/Linux):
if_wordsize(64,
compiler_stats_num_field('bytes allocated', 540000000,
620000000)),
compiler_stats_range_field('bytes allocated', 587079016, 5)),
only_ways(['normal']),
],
compile_fail, [''])
......
......@@ -8,8 +8,7 @@ test('haddock.base',
# 2012-11-12: 249 (amd64/Linux)
# 2013-01-29: 274 (amd64/Linux)
,if_wordsize(32,
stats_num_field('peak_megabytes_allocated', 110,
115))
stats_range_field('peak_megabytes_allocated', 113, 1))
# 2012-08-14: 144 (x86/OSX)
# 2012-10-30: 113 (x86/Windows)
,if_wordsize(64,
......@@ -45,8 +44,7 @@ test('haddock.Cabal',
# 2012-09-20: 227 (amd64/Linux)
# 2012-10-08: 217 (amd64/Linux)
,if_wordsize(32,
stats_num_field('peak_megabytes_allocated', 80,
85))
stats_range_field('peak_megabytes_allocated', 83, 1))
# 2012-08-14: 116 (x86/OSX)
# 2012-10-30: 83 (x86/Windows)
,if_wordsize(64,
......@@ -81,8 +79,7 @@ test('haddock.compiler',
# 2012-09-20: 1228 (amd64/Linux)
# 2012-10-08: 1240 (amd64/Linux)
,if_wordsize(32,
stats_num_field('peak_megabytes_allocated', 600,
610))
stats_range_field('peak_megabytes_allocated', 606, 1))
# 2012-08-14: 631 (x86/OSX)
# 2012-10-30: 606 (x86/Windows)
,if_wordsize(64,
......
......@@ -4,11 +4,9 @@
# because the test allocates an unboxed array of doubles.
test('T3586',
[stats_num_field('peak_megabytes_allocated', 17,
18),
[stats_range_field('peak_megabytes_allocated', 17, 1),
# expected value: 17 (amd64/Linux)
stats_num_field('bytes allocated', 16000000,
17000000),
stats_range_field('bytes allocated', 16835544, 5),
# expected value: 16835544 (amd64/Linux)
only_ways(['normal'])
],
......@@ -16,8 +14,7 @@ test('T3586',
['-O'])
test('T4830',
[stats_num_field('bytes allocated', 60000,
200000),
[stats_range_field('bytes allocated', 127000, 5),
# expected value: 127,000 (amd64/Linux)
only_ways(['normal'])
],
......@@ -30,11 +27,9 @@ test('T3245', normal, compile_and_run, ['-O'])
# a bug in hGetBufNonBlocking in 6.13 that triggered this.
#
test('lazy-bs-alloc',
[stats_num_field('peak_megabytes_allocated', 1,
3),
[stats_range_field('peak_megabytes_allocated', 2, 1),
# expected value: 2 (amd64/Linux)
stats_num_field('bytes allocated', 400000,
600000),
stats_range_field('bytes allocated', 489776, 5),
# expected value: 489776 (amd64/Linux)
only_ways(['normal']),
extra_run_opts('../../numeric/should_run/arith011.stdout'),
......@@ -60,16 +55,13 @@ test('T3736',
['$MAKE -s --no-print-directory T3736'])
test('T3738',
[extra_clean(['T3738a.hi', 'T3738a.o']),
stats_num_field('peak_megabytes_allocated', 1,
1),
stats_range_field('peak_megabytes_allocated', 1, 0),
# expected value: 1 (amd64/Linux)
# expected value: 45648 (x86/Linux):
if_wordsize(32,
stats_num_field('bytes allocated', 40000,
50000)),
stats_range_field('bytes allocated', 45648, 5)),
# expected value: 45648 (x86/Linux):
if_wordsize(64,
stats_num_field('bytes allocated', 40000,
60000)),
stats_range_field('bytes allocated', 49400, 5)),
# expected value: 49400 (amd64/Linux)
only_ways(['normal'])
],
......@@ -77,17 +69,14 @@ test('T3738',
['-O'])
test('MethSharing',
[stats_num_field('peak_megabytes_allocated', 1,
1),
[stats_range_field('peak_megabytes_allocated', 1, 0),
# expected value: 1 (amd64/Linux)
# expected value: 2685858140 (x86/OS X):
if_wordsize(32,
stats_num_field('bytes allocated', 300000000,
400000000)),
stats_range_field('bytes allocated', 360940756, 5)),
# expected: 360940756 (x86/Linux)
if_wordsize(64,
stats_num_field('bytes allocated', 600000000,
700000000)),
stats_range_field('bytes allocated', 640067672, 5)),
# expected: 640067672 (amd64/Linux)
only_ways(['normal'])
],
......@@ -114,11 +103,9 @@ test('T149',
test('T5113',
[
if_wordsize(32,
stats_num_field('bytes allocated', 3000000,
5000000)),
stats_range_field('bytes allocated', 4000000, 5)),
if_wordsize(64,
stats_num_field('bytes allocated', 8000000,
9000000)),
stats_range_field('bytes allocated', 8000000, 5)),
only_ways(['normal']),
expect_broken(7046)
],
......@@ -128,11 +115,9 @@ test('T5113',
test('T4978',
[if_wordsize(32,
stats_num_field('bytes allocated', 9000000,
11000000)),
stats_range_field('bytes allocated', 10000000, 5)),
if_wordsize(64,
stats_num_field('bytes allocated', 9000000,
11000000)),
stats_range_field('bytes allocated', 10137680, 5)),
# expected value: 10137680 (amd64/Linux)
only_ways(['normal'])
],
......@@ -141,12 +126,10 @@ test('T4978',
test('T5205',
[if_wordsize(32,
stats_num_field('bytes allocated', 40000,
50000)),
stats_range_field('bytes allocated', 47088, 5)),
# expected value: 47088 (x86/Darwin)
if_wordsize(64,
stats_num_field('bytes allocated', 40000,
60000)),
stats_range_field('bytes allocated', 51320, 5)),
# expected value: 51320 (amd64/Linux)
only_ways(['normal', 'optasm'])
],
......@@ -155,12 +138,10 @@ test('T5205',
test('T5549',
[if_wordsize(32,
stats_num_field('bytes allocated', 3000000000,
8000000000)),
stats_range_field('bytes allocated', 3362958676, 5)),
# expected value: 3362958676 (Windows)
if_wordsize(64,
stats_num_field('bytes allocated', 5000000000,
8000000000)),
stats_range_field('bytes allocated', 6725846120, 5)),
# expected value: 6,725,846,120 (amd64/Linux)
only_ways(['normal'])
],
......@@ -169,12 +150,10 @@ test('T5549',
test('T4474a',
[if_wordsize(32,
stats_num_field('bytes allocated', 1600000000,
2000000000)),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
stats_num_field('bytes allocated', 3500000000,
3900000000)),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
],
......@@ -182,12 +161,10 @@ test('T4474a',
['-O'])
test('T4474b',
[if_wordsize(32,
stats_num_field('bytes allocated', 1600000000,
2000000000)),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
stats_num_field('bytes allocated', 3500000000,
3900000000)),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
],
......@@ -195,12 +172,10 @@ test('T4474b',
['-O'])
test('T4474c',
[if_wordsize(32,
stats_num_field('bytes allocated', 1600000000,
2000000000)),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
stats_num_field('bytes allocated', 3500000000,
3900000000)),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
],
......@@ -209,12 +184,10 @@ test('T4474c',
test('T5237',
[if_wordsize(32,
stats_num_field('bytes allocated', 70000,
90000)),
stats_range_field('bytes allocated', 78328, 5)),
# expected value: 78328 (i386/Linux)
if_wordsize(64,
stats_num_field('bytes allocated', 90000,
130000)),
stats_range_field('bytes allocated', 110888, 5)),
# expected value: 110888 (amd64/Linux)
only_ways(['normal'])
],
......@@ -223,8 +196,7 @@ test('T5237',
test('T5536',
[if_wordsize(32,
stats_num_field('bytes allocated', 1150000000,
1250000000)),
stats_range_field('bytes allocated', 1246287228, 5)),
# expected value: 1246287228 (i386/Linux)
if_wordsize(64,
stats_range_field('bytes allocated', 892399040, 5)),
......@@ -272,8 +244,7 @@ test('T7507', omit_ways(['ghci']), compile_and_run, ['-O'])
# For 7507, stack overflow is the bad case
test('T7436',
[stats_num_field('max_bytes_used', 50000,
100000),
[stats_range_field('max_bytes_used', 70000, 5),
# expected value: 127,000 (amd64/Linux)
only_ways(['normal'])
],
......
......@@ -4,15 +4,13 @@ test('space_leak_001',
# Now it's: 3 (amd64/Linux)
# 4 (x86/OS X)
# 5 (x86/Linux)
[stats_num_field('peak_megabytes_allocated', 3, 5),
stats_num_field('max_bytes_used', 400000,
500000),
[stats_range_field('peak_megabytes_allocated', 4, 1),
stats_range_field('max_bytes_used', 481456, 1),
# expected value: 440224 (amd64/Linux)
# 417016 (x86/OS X)
# 415672 (x86/Windows)
# 481456 (unreg amd64/Linux)
stats_num_field('bytes allocated', 9050000000,
9100000000),
stats_range_field('bytes allocated', 9079316016, 1),
# expected value: 9079316016 (amd64/Linux)
# 9331570416 (x86/Linux)
# 9329073952 (x86/OS X)
......@@ -25,7 +23,7 @@ test('space_leak_001',
test('T4334',
# Test for a space leak in Data.List.lines (fixed with #4334)
[extra_run_opts('1000000 2 t'),
stats_num_field('peak_megabytes_allocated', 1, 3),
stats_range_field('peak_megabytes_allocated', 2, 0),
# prof ways don't work well with +RTS -V0
omit_ways(['profasm','profthreaded'])
],
......@@ -34,7 +32,7 @@ test('T4334',
test('T2762',
[# peak_megabytes_allocated is 2 with 7.0.2.
# Was 57 with 6.12.3.
stats_num_field('peak_megabytes_allocated', 1, 3),
stats_range_field('peak_megabytes_allocated', 2, 0),
only_ways(['normal']),
extra_clean(['T2762A.hi', 'T2762A.o'])],
compile_and_run, ['-O'])
......
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