Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Charles Burton
Gaudi
Commits
e23eadaf
Commit
e23eadaf
authored
Sep 11, 2012
by
Marco Clemencic
Browse files
Improved the timing_histos test to check the content of the rootfile.
parent
3af8b314
Changes
2
Hide whitespace changes
Inline
Side-by-side
GaudiExamples/tests/qmtest/gaudiexamples.qms/timing_histos.qmt
View file @
e23eadaf
<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension
class=
"GaudiTest.GaudiExeTest"
kind=
"test"
>
<argument
name=
"program"
><text>
gaudirun.py
</text></argument>
<argument
name=
"args"
><set><text>
$GAUDIEXAMPLESROOT/options/TimingHistograms.py
</text></set></argument>
<argument
name=
"use_temp_dir"
><enumeral>
true
</enumeral></argument>
<argument
name=
"reference"
><text>
refs/TimingHistograms.ref
</text></argument>
<argument
name=
"program"
><text>
gaudirun.py
</text></argument>
<argument
name=
"args"
><set><text>
$GAUDIEXAMPLESROOT/options/TimingHistograms.py
</text></set></argument>
<argument
name=
"use_temp_dir"
><enumeral>
true
</enumeral></argument>
<argument
name=
"reference"
><text>
refs/TimingHistograms.ref
</text></argument>
<argument
name=
"validator"
><text>
# Default validation.
validateWithReference()
# Check the content of the ROOT file.
import os
from subprocess import Popen, PIPE
testscript = os.path.join(os.environ['GAUDIEXAMPLESROOT'], 'tests', 'scripts', 'test_timing_histo_file.py')
test = Popen(['python', testscript], stdout=PIPE, stderr=PIPE)
out, err = test.communicate()
result['root_file_check.returncode'] = str(test.returncode)
if test.returncode:
causes.append('root file content')
if out:
result['root_file_check.stdout'] = result.Quote(out)
if err:
causes.append('standard error')
result['root_file_check.stderr'] = result.Quote(err)
</text></argument>
</extension>
GaudiExamples/tests/scripts/test_timing_histo_file.py
0 → 100755
View file @
e23eadaf
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Check the content of the ROOT file generated by the test 'gaudiexamples.timing_histos'.
The file must contain a directory called 'TIMER.TIMER' with 3 well defined histograms inside.
"""
import
sys
def
test
():
import
ROOT
filename
=
'timing_histos.root'
toolname
=
'TIMER.TIMER'
histograms
=
[
'ElapsedTime'
,
'CPUTime'
,
'Count'
]
labels
=
[
'EVENT LOOP '
,
' ParentAlg '
,
' SubAlg1 '
,
' SubAlg2 '
,
' StopperAlg '
,
' TopSequence '
,
' Sequence1 '
,
' Prescaler1 '
,
' HelloWorld '
,
' Counter1 '
,
' Sequence2 '
,
' Prescaler2 '
,
' Counter2 '
,
' ANDSequence '
,
' AND '
,
' ANDCounter '
,
' ORSequence '
,
' OR '
,
' ORCounter '
]
f
=
ROOT
.
TFile
.
Open
(
filename
)
assert
f
,
'Cannot open file %r'
%
filename
d
=
f
.
Get
(
toolname
)
assert
d
,
'Missing directory %r'
%
toolname
for
name
in
histograms
:
h
=
d
.
Get
(
name
)
assert
h
,
'Missing histogram %r'
%
name
l
=
list
(
h
.
GetXaxis
().
GetLabels
())
assert
len
(
l
)
==
len
(
labels
),
'Wrong number of labels in histogram %r (found: %d, exp: %d)'
%
(
name
,
len
(
l
),
len
(
labels
))
for
i
,
(
expected
,
found
)
in
enumerate
(
zip
(
labels
,
l
)):
assert
found
==
expected
,
'Wrong label at position %d in histogram %r (found: %r, exp: %r)'
%
(
i
,
name
,
found
,
expected
)
if
__name__
==
'__main__'
:
try
:
test
()
except
AssertionError
,
a
:
print
"FAILURE:"
,
a
sys
.
exit
(
1
)
print
"SUCCESS"
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