Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
6c3a7be9
Commit
6c3a7be9
authored
Nov 04, 2013
by
Lynn Garren
Browse files
use unique stream names in Random/test and allow for dependencies between tests
parent
9e33b998
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
6c3a7be9
2013-11-04 Lynn Garren <garren@fnal.gov>
* Random/test: make sure all output streams have unique names
2013-10-31 Lynn Garren <garren@fnal.gov>
...
...
Random/ChangeLog
View file @
6c3a7be9
2013-11-04 Lynn Garren <garren@fnal.gov>
* Random/test: make sure all output streams have unique names
2013-10-31 Lynn Garren <garren@fnal.gov>
* Random/src/RandGaussZiggurat.cc - fix potential shadowing issue
...
...
Random/test/CMakeLists.txt
View file @
6c3a7be9
...
...
@@ -3,28 +3,28 @@ set( Random_tests testRandom
testRandDists
)
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
)
set
(
Random_simple_tests testSaveEngineStatus
testInstanceRestore
testSaveSharedEngines
testStaticStreamSave
testAnonymousEngineRestore
testVectorSave
testBug73093
testEngineCopy
testDistCopy
testRanecuSequence
)
testInstanceRestore
testSaveSharedEngines
testStaticStreamSave
testAnonymousEngineRestore
testVectorSave
testBug73093
testEngineCopy
testDistCopy
testRanecuSequence
)
else
()
set
(
Random_simple_tests testSaveEngineStatus
testInstanceRestore
testSaveSharedEngines
testStaticStreamSave
testAnonymousEngineRestore
testVectorSave
testBug58950
testBug73093
testEngineCopy
testDistCopy
testZiggurat
testRanecuSequence
)
testInstanceRestore
testSaveSharedEngines
testStaticStreamSave
testAnonymousEngineRestore
testVectorSave
testBug58950
testBug73093
testEngineCopy
testDistCopy
testZiggurat
testRanecuSequence
)
endif
()
foreach
(
test
${
Random_tests
}
)
...
...
Random/test/Makefile.am
View file @
6c3a7be9
...
...
@@ -80,7 +80,10 @@ EXTRA_DIST = \
CLEANFILES
=
testRandom.sh testRandDists.sh
\
gaussSpeed.sh gaussSmall.sh testRandom.out
\
distribution.save distribution.save1 distribution.save2
\
engine.save shared.save1 shared.save2
\
anon_distribution.save instance_distribution.save instance2_distribution.save
\
ss1_distribution.save ss2_distribution.save ss_distribution.save
\
engine.save anon_engine.save instance_engine.save
\
shared.save1 shared.save2 t1_shared.save t2_shared.save
\
testSaveEngineStatus.cout testInstanceRestore.cout
\
testSaveSharedEngines.cout testStaticStreamSave.cout
\
testAnonymousEngineRestore.cout testVectorSave.cout
\
...
...
Random/test/testAnonymousEngineRestore.cc
View file @
6c3a7be9
...
...
@@ -198,13 +198,13 @@ int anonymousRestoreStatics1() {
HepRandom
::
setTheEngine
(
e
);
randomizeStatics
(
15
);
output
<<
"
\n
Randomized, with theEngine = "
<<
e
->
name
()
<<
"
\n
"
;
saveStatics
(
"distribution.save"
);
saveStatics
(
"
anon_
distribution.save"
);
output
<<
"Saved all static distributions
\n
"
;
std
::
vector
<
double
>
c
=
captureStatics
();
output
<<
"Captured output of all static distributions
\n
"
;
randomizeStatics
(
11
);
output
<<
"Randomized all static distributions
\n
"
;
restoreStatics
(
"distribution.save"
);
restoreStatics
(
"
anon_
distribution.save"
);
output
<<
"Restored all static distributions to saved state
\n
"
;
std
::
vector
<
double
>
d
=
captureStatics
();
output
<<
"Captured output of all static distributions
\n
"
;
...
...
@@ -237,7 +237,7 @@ int anonymousRestoreStatics() {
HepRandom
::
setTheEngine
(
e1
);
randomizeStatics
(
15
);
output
<<
"
\n
Randomized, with theEngine = "
<<
e1
->
name
()
<<
"
\n
"
;
saveStatics
(
"distribution.save"
);
saveStatics
(
"
anon_
distribution.save"
);
#ifdef VERBOSER2
output
<<
"Saved all static distributions
\n
"
;
#endif
...
...
@@ -250,16 +250,16 @@ int anonymousRestoreStatics() {
HepRandom
::
setTheEngine
(
e2
);
output
<<
"Switched to theEngine = "
<<
e2
->
name
()
<<
"
\n
"
;
randomizeStatics
(
19
);
{
std
::
ofstream
os
(
"engine.save"
);
os
<<
*
e2
;
}
{
std
::
ofstream
os
(
"
anon_
engine.save"
);
os
<<
*
e2
;
}
double
v1
=
e2
->
flat
();
double
v2
=
e2
->
flat
();
{
std
::
ifstream
is
(
"engine.save"
);
is
>>
*
e2
;
}
{
std
::
ifstream
is
(
"
anon_
engine.save"
);
is
>>
*
e2
;
}
#ifdef VERBOSER2
output
<<
"Saved the "
<<
e2
->
name
()
<<
" engine:
\n
"
<<
"Next randoms to be "
<<
v1
<<
" "
<<
v2
<<
"
\n
"
<<
"Restored the "
<<
e2
->
name
()
<<
" engine to that state
\n
"
;
#endif
restoreStatics
(
"distribution.save"
);
restoreStatics
(
"
anon_
distribution.save"
);
#ifdef VERBOSER2
output
<<
"Restored all static distributions to saved state
\n
"
<<
"This changes the engine type back to "
<<
E1
::
engineName
()
<<
"
\n
"
;
...
...
Random/test/testInstanceRestore.cc
View file @
6c3a7be9
...
...
@@ -99,7 +99,7 @@ int checkEngineInstanceSave(E & e) {
int
pr
=
output
.
precision
(
20
);
double
r
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
r
+=
e
.
flat
();
{
std
::
ofstream
os
(
"engine.save"
);
os
<<
e
;}
{
std
::
ofstream
os
(
"
instance_
engine.save"
);
os
<<
e
;}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
r
+=
e
.
flat
();
double
keyValue1
=
e
.
flat
();
double
keyValue2
=
e
.
flat
();
...
...
@@ -107,7 +107,7 @@ int checkEngineInstanceSave(E & e) {
output
<<
keyValue1
<<
" "
<<
keyValue2
<<
"
\n
"
;
#endif
E
e2
;
{
std
::
ifstream
is
(
"engine.save"
);
is
>>
e2
;}
{
std
::
ifstream
is
(
"
instance_
engine.save"
);
is
>>
e2
;}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
r
+=
e2
.
flat
();
double
k1
=
e2
.
flat
();
double
k2
=
e2
.
flat
();
...
...
@@ -136,12 +136,12 @@ int checkSaveDistribution(D & d, int nth) {
r
=
d
();
double
keyValue1
,
keyValue2
,
keyValue3
,
keyValue4
;
for
(
int
i
=
0
;
i
<
nth
;
i
++
)
r
+=
d
();
{
std
::
ofstream
os
(
"distribution.save
1
"
);
os
<<
d
.
engine
()
<<
d
;}
{
std
::
ofstream
os
(
"
instance_
distribution.save"
);
os
<<
d
.
engine
()
<<
d
;}
keyValue1
=
d
();
keyValue2
=
d
();
r
+=
d
();
// A second capture will test non-cached if first tested cached case:
{
std
::
ofstream
os
(
"distribution.save
2
"
);
os
<<
d
.
engine
()
<<
d
;}
{
std
::
ofstream
os
(
"
instance2_
distribution.save"
);
os
<<
d
.
engine
()
<<
d
;}
keyValue3
=
d
();
keyValue4
=
d
();
int
pr
=
output
.
precision
(
20
);
...
...
@@ -154,10 +154,10 @@ int checkSaveDistribution(D & d, int nth) {
output
.
precision
(
pr
);
E
e
;
D
d2
(
e
);
{
std
::
ifstream
is
(
"distribution.save
1
"
);
is
>>
e
>>
d2
;}
{
std
::
ifstream
is
(
"
instance_
distribution.save"
);
is
>>
e
>>
d2
;}
double
k1
=
d2
();
double
k2
=
d2
();
{
std
::
ifstream
is
(
"distribution.save
2
"
);
is
>>
e
>>
d2
;}
{
std
::
ifstream
is
(
"
instance2_
distribution.save"
);
is
>>
e
>>
d2
;}
double
k3
=
d2
();
double
k4
=
d2
();
#ifdef VERBOSER
...
...
@@ -192,12 +192,12 @@ int checkRandGeneralDistribution(RandGeneral & d, int nth) {
r
=
d
();
double
keyValue1
,
keyValue2
,
keyValue3
,
keyValue4
;
for
(
int
i
=
0
;
i
<
nth
;
i
++
)
r
+=
d
();
{
std
::
ofstream
os
(
"distribution.save
1
"
);
os
<<
d
.
engine
()
<<
d
;}
{
std
::
ofstream
os
(
"
instance_
distribution.save"
);
os
<<
d
.
engine
()
<<
d
;}
keyValue1
=
d
();
keyValue2
=
d
();
r
+=
d
();
// A second capture will test non-cached if first tested cached case:
{
std
::
ofstream
os
(
"distribution.save
2
"
);
os
<<
d
.
engine
()
<<
d
;}
{
std
::
ofstream
os
(
"
instance2_
distribution.save"
);
os
<<
d
.
engine
()
<<
d
;}
keyValue3
=
d
();
keyValue4
=
d
();
int
pr
=
output
.
precision
(
20
);
...
...
@@ -211,10 +211,10 @@ int checkRandGeneralDistribution(RandGeneral & d, int nth) {
E
e
;
double
temp
=
1
;
RandGeneral
d2
(
e
,
&
temp
,
1
);
{
std
::
ifstream
is
(
"distribution.save
1
"
);
is
>>
e
>>
d2
;}
{
std
::
ifstream
is
(
"
instance_
distribution.save"
);
is
>>
e
>>
d2
;}
double
k1
=
d2
();
double
k2
=
d2
();
{
std
::
ifstream
is
(
"distribution.save
2
"
);
is
>>
e
>>
d2
;}
{
std
::
ifstream
is
(
"
instance2_
distribution.save"
);
is
>>
e
>>
d2
;}
double
k3
=
d2
();
double
k4
=
d2
();
#ifdef VERBOSER
...
...
Random/test/testSaveSharedEngines.cc
View file @
6c3a7be9
...
...
@@ -51,14 +51,14 @@ int checkSharingDistributions(D1 & d1, D2 & d2, int n1, int n2) {
double
kv21
,
kv22
,
kv23
,
kv24
;
for
(
int
i
=
0
;
i
<
n1
;
i
++
)
r
+=
d1
();
for
(
int
j
=
0
;
j
<
n2
;
j
++
)
r
+=
d2
();
{
std
::
ofstream
os
(
"shared.save
1
"
);
os
<<
d1
.
engine
()
<<
d1
<<
d2
;}
{
std
::
ofstream
os
(
"
t1_
shared.save"
);
os
<<
d1
.
engine
()
<<
d1
<<
d2
;}
kv11
=
d1
();
kv21
=
d2
();
kv12
=
d1
();
kv22
=
d2
();
r
+=
d1
()
+
d2
();
// A second capture will test non-cached if first tested cached case:
{
std
::
ofstream
os
(
"shared.save
2
"
);
os
<<
d1
.
engine
()
<<
d1
<<
d2
;}
{
std
::
ofstream
os
(
"
t2_
shared.save"
);
os
<<
d1
.
engine
()
<<
d1
<<
d2
;}
kv13
=
d1
();
kv23
=
d2
();
kv14
=
d1
();
...
...
@@ -78,12 +78,12 @@ int checkSharingDistributions(D1 & d1, D2 & d2, int n1, int n2) {
E
e
;
D1
d1r
(
e
);
D2
d2r
(
e
);
{
std
::
ifstream
is
(
"shared.save
1
"
);
is
>>
e
>>
d1r
>>
d2r
;}
{
std
::
ifstream
is
(
"
t1_
shared.save"
);
is
>>
e
>>
d1r
>>
d2r
;}
double
k11
=
d1r
();
double
k21
=
d2r
();
double
k12
=
d1r
();
double
k22
=
d2r
();
{
std
::
ifstream
is
(
"shared.save
2
"
);
is
>>
e
>>
d1r
>>
d2r
;}
{
std
::
ifstream
is
(
"
t2_
shared.save"
);
is
>>
e
>>
d1r
>>
d2r
;}
double
k13
=
d1r
();
double
k23
=
d2r
();
double
k14
=
d1r
();
...
...
Random/test/testStaticStreamSave.cc
View file @
6c3a7be9
...
...
@@ -48,7 +48,7 @@ int staticSave(int n) {
double
v1
,
v2
,
k1
,
k2
;
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ofstream
file
(
"distribution.save
1
"
);
std
::
ofstream
file
(
"
ss1_
distribution.save"
);
D
::
saveFullState
(
file
);
v1
=
D
::
shoot
();
D
::
saveFullState
(
file
);
...
...
@@ -61,7 +61,7 @@ int staticSave(int n) {
}
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ifstream
file
(
"distribution.save
1
"
);
std
::
ifstream
file
(
"
ss1_
distribution.save"
);
D
::
restoreFullState
(
file
);
k1
=
D
::
shoot
();
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
...
...
@@ -83,7 +83,7 @@ int staticSave(int n) {
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ofstream
file
(
"distribution.save
2
"
);
std
::
ofstream
file
(
"
ss2_
distribution.save"
);
D
::
saveDistState
(
file
)
<<
*
D
::
getTheEngine
();
v1
=
D
::
shoot
();
D
::
saveDistState
(
file
)
<<
*
D
::
getTheEngine
();
...
...
@@ -96,7 +96,7 @@ int staticSave(int n) {
}
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ifstream
file
(
"distribution.save
2
"
);
std
::
ifstream
file
(
"
ss2_
distribution.save"
);
D
::
restoreDistState
(
file
)
>>
*
D
::
getTheEngine
();
k1
=
D
::
shoot
();
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
...
...
@@ -130,7 +130,7 @@ int staticSaveShootBit(int n) {
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
for
(
i
=
0
;
i
<
n
;
i
++
)
bit
|=
D
::
shootBit
();
{
std
::
ofstream
file
(
"distribution.save
1
"
);
std
::
ofstream
file
(
"
ss1_
distribution.save"
);
D
::
saveFullState
(
file
);
v1
=
0
;
for
(
i
=
0
;
i
<
25
;
i
++
)
{
...
...
@@ -152,7 +152,7 @@ int staticSaveShootBit(int n) {
}
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ifstream
file
(
"distribution.save
1
"
);
std
::
ifstream
file
(
"
ss1_
distribution.save"
);
D
::
restoreFullState
(
file
);
k1
=
0
;
for
(
i
=
0
;
i
<
25
;
i
++
)
{
...
...
@@ -183,7 +183,7 @@ int staticSaveShootBit(int n) {
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
for
(
i
=
0
;
i
<
n
;
i
++
)
bit
|=
D
::
shootBit
();
{
std
::
ofstream
file
(
"distribution.save
2
"
);
std
::
ofstream
file
(
"
ss2_
distribution.save"
);
D
::
saveDistState
(
file
)
<<
*
D
::
getTheEngine
();
v1
=
0
;
for
(
i
=
0
;
i
<
25
;
i
++
)
{
...
...
@@ -205,7 +205,7 @@ int staticSaveShootBit(int n) {
}
for
(
i
=
0
;
i
<
n
;
i
++
)
r
+=
D
::
shoot
();
{
std
::
ifstream
file
(
"distribution.save
2
"
);
std
::
ifstream
file
(
"
ss2_
distribution.save"
);
D
::
restoreDistState
(
file
)
>>
*
D
::
getTheEngine
();
k1
=
0
;
for
(
i
=
0
;
i
<
25
;
i
++
)
{
...
...
@@ -342,13 +342,13 @@ int main() {
output
<<
"==============================================
\n\n
"
;
randomizeStatics
(
15
);
saveStatics
(
"distribution.save"
);
saveStatics
(
"
ss_
distribution.save"
);
output
<<
"Saved all static distributions
\n
"
;
std
::
vector
<
double
>
c
=
captureStatics
();
output
<<
"Captured output of all static distributions
\n
"
;
randomizeStatics
(
11
);
output
<<
"Randomized all static distributions
\n
"
;
restoreStatics
(
"distribution.save"
);
restoreStatics
(
"
ss_
distribution.save"
);
output
<<
"Restored all static distributions to saved state
\n
"
;
std
::
vector
<
double
>
d
=
captureStatics
();
output
<<
"Captured output of all static distributions
\n
"
;
...
...
cmake/Modules/ClhepBuildTest.cmake
View file @
6c3a7be9
# Create the tests
#
# if using a shell script:
# clhep_test( testname [SIMPLE] [FAIL] [NOLIB] )
# where testname is the base name of the .cc and .sh.in file
# clhep_test( testname
# [LIBS] <library_list>
# [DEPENDS] <another_testname>
# [SIMPLE] - this test does not require a shell script
# [FAIL] - test is epected to fail
# [NOLIB] - no library dependencies
# )
# testname is the base name of the .cc file
#
# if the test requires running a shell script:
# clhep_test( testname )
# testname is the base name of the .cc and .sh.in file
#
include
(
ClhepParseArgs
)
macro
(
clhep_test testname
)
clhep_parse_args
(
CTST
"LIBS"
"SIMPLE;FAIL;NOLIB"
${
ARGN
}
)
clhep_parse_args
(
CTST
"LIBS
;DEPENDS
"
"SIMPLE;FAIL;NOLIB"
${
ARGN
}
)
# automake/autoconf variables for ${testname}.sh.in
set
(
srcdir
${
CMAKE_CURRENT_SOURCE_DIR
}
)
...
...
@@ -39,6 +48,10 @@ macro( clhep_test testname )
if
(
CTST_FAIL
)
set_tests_properties
(
${
testname
}
PROPERTIES WILL_FAIL TRUE
)
endif
()
if
(
CTST_DEPENDS
)
set_tests_properties
(
${
testname
}
PROPERTIES DEPENDS
${
CTST_DEPENDS
}
)
#message(STATUS "clhep_test: ${testname} depends on ${CTST_DEPENDS}")
endif
(
CTST_DEPENDS
)
else
()
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
)
message
(
STATUS
"skipping
${
testname
}
.sh on
${
CMAKE_SYSTEM_NAME
}
"
)
...
...
@@ -49,6 +62,10 @@ macro( clhep_test testname )
if
(
CTST_FAIL
)
set_tests_properties
(
${
testname
}
.sh PROPERTIES WILL_FAIL TRUE
)
endif
()
if
(
CTST_DEPENDS
)
add_custom_target
(
check COMMAND
${
testname
}
DEPENDS
${
CTST_DEPENDS
}
)
endif
(
CTST_DEPENDS
)
endif
()
endif
()
endmacro
(
clhep_test
)
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