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

Add a different sort of stats_num_field helper function

Uses look like
    stats_num_field('bytes allocated',
                    [(wordsize(32), 45648, 5),
                     (wordsize(64), 49400, 5)])
where the first matching triple will be used. e.g. we could override
the Win32 expected values with:
                    [(platform('i386-unknown-mingw32'), 41000, 5),
                     (wordsize(32),                     45648, 5),
                     (wordsize(64),                     49400, 5)])
with other 32-bit platforms falling through to the wordsize(32) case.

This makes it easier to give different values for different platforms,
while being sure that all platforms are covered.
parent 83a6ae94
......@@ -251,17 +251,39 @@ def _extra_clean( name, opts, v ):
# -----
def stats_num_field( field, expecteds ):
return lambda name, opts, f=field, e=expecteds: _stats_num_field(name, opts, f, e);
def _stats_num_field( name, opts, field, expecteds ):
if field in opts.stats_range_fields:
framework_fail(name, 'duplicate-numfield', 'Duplicate ' + field + ' num_field check')
for (b, expected, dev) in expecteds:
if b:
opts.stats_range_fields[field] = (expected, dev)
return
framework_fail(name, 'numfield-no-expected', 'No expected value found for ' + field + ' in num_field check')
def stats_range_field( field, expected, dev ):
return lambda name, opts, f=field, x=expected, y=dev: _stats_range_field(name, opts, f, x, y);
return stats_num_field( field, [(True, expected, dev)] )
def _stats_range_field( name, opts, f, x, y ):
opts.stats_range_fields[f] = (x, y)
def compiler_stats_num_field( field, expecteds ):
return lambda name, opts, f=field, e=expecteds: _compiler_stats_num_field(name, opts, f, e);
def compiler_stats_range_field( field, expected, dev ):
return lambda name, opts, f=field, x=expected, y=dev: _compiler_stats_range_field(name, opts, f, x, y);
def _compiler_stats_num_field( name, opts, field, expecteds ):
if field in opts.compiler_stats_range_fields:
framework_fail(name, 'duplicate-numfield', 'Duplicate ' + field + ' num_field check')
for (b, expected, dev) in expecteds:
if b:
opts.compiler_stats_range_fields[field] = (expected, dev)
return
def _compiler_stats_range_field( name, opts, f, x, y ):
opts.compiler_stats_range_fields[f] = (x, y)
framework_fail(name, 'numfield-no-expected', 'No expected value found for ' + field + ' in num_field check')
def compiler_stats_range_field( field, expected, dev ):
return compiler_stats_num_field( field, [(True, expected, dev)] )
# -----
......
......@@ -59,12 +59,11 @@ test('T3738',
[extra_clean(['T3738a.hi', 'T3738a.o']),
stats_range_field('peak_megabytes_allocated', 1, 0),
# expected value: 1 (amd64/Linux)
when(wordsize(32),
stats_range_field('bytes allocated', 45648, 5)),
# expected value: 45648 (x86/Linux):
when(wordsize(64),
stats_range_field('bytes allocated', 49400, 5)),
# expected value: 49400 (amd64/Linux)
stats_num_field('bytes allocated',
[(wordsize(32), 45648, 5),
# expected value: 45648 (x86/Linux)
(wordsize(64), 49400, 5)]),
# expected value: 49400 (amd64/Linux)
only_ways(['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