Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
6ed02034
Commit
6ed02034
authored
Apr 03, 2009
by
Ian Lynagh
Browse files
Improve the testsuite driver support for -t stats, and enhance space_leak_001
parent
abf55148
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/driver/testglobals.py
View file @
6ed02034
...
...
@@ -176,11 +176,13 @@ 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
# which -t numeric fields do we want to look at, and what bounds must
# they fall within?
# Elements of this list should be things like
# ('bytes allocated',
# 9300000000,
# 9400000000)
self
.
stats_num_fields
=
[]
# should we run this test alone, i.e. not run it in parallel with
# any other threads
...
...
testsuite/driver/testlib.py
View file @
6ed02034
...
...
@@ -216,13 +216,11 @@ def _extra_clean( opts, v ):
# -----
def
s
pace
(
field
,
min
,
max
):
return
lambda
opts
,
f
=
field
,
n
=
min
,
x
=
max
:
_s
pace
(
opts
,
f
,
n
,
x
);
def
s
tats_num_field
(
field
,
min
,
max
):
return
lambda
opts
,
f
=
field
,
x
=
min
,
y
=
max
:
_s
tats_num_field
(
opts
,
f
,
x
,
y
);
def
_space
(
opts
,
f
,
n
,
x
):
opts
.
space_field
=
f
opts
.
space_min
=
n
opts
.
space_max
=
x
def
_stats_num_field
(
opts
,
f
,
x
,
y
):
opts
.
stats_num_fields
=
opts
.
stats_num_fields
+
[(
f
,
x
,
y
)]
# -----
...
...
@@ -671,37 +669,6 @@ 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
(
in_testdir
(
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
)
...
...
@@ -780,6 +747,10 @@ def simple_run( name, way, prog, args ):
my_rts_flags
=
rts_flags
(
way
)
if
opts
.
stats_num_fields
!=
[]:
stats_file
=
name
+
'.stats'
args
+=
' +RTS -t'
+
stats_file
+
' --machine-readable -RTS'
if
opts
.
no_stdin
:
stdin_comes_from
=
''
else
:
...
...
@@ -818,6 +789,31 @@ def simple_run( name, way, prog, args ):
if
check_prof
and
not
check_prof_ok
(
name
):
return
'fail'
if
opts
.
stats_num_fields
!=
[]:
num_field_fail
=
False
f
=
open
(
in_testdir
(
stats_file
))
contents
=
f
.
read
()
f
.
close
()
for
(
field
,
min
,
max
)
in
opts
.
stats_num_fields
:
m
=
re
.
search
(
'\("'
+
field
+
'", "([0-9]+)"\)'
,
contents
)
if
m
==
None
:
print
'Failed to find field: '
,
field
return
'fail'
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'
num_field_fail
=
True
if
val
>
max
:
print
field
,
val
,
'is more than maximum allowed'
,
max
num_field_fail
=
True
if
num_field_fail
:
return
'fail'
return
'pass'
def
rts_flags
(
way
):
...
...
testsuite/tests/ghc-regress/space_leaks/all.T
View file @
6ed02034
test
('
space_leak_001
',
# Before trac #2747 was fixed this was 565, after it was 3
space
('
peak_megabytes_allocated
',
1
,
5
),
compile_and_run_space
,
[
stats_num_field
('
peak_megabytes_allocated
',
3
,
3
),
stats_num_field
('
max_bytes_used
',
430000
,
450000
),
# expected value: 440224
stats_num_field
('
bytes allocated
',
9340000000
,
9350000000
)],
# expected value: 9343740368
compile_and_run
,
[''])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment