Commit 6c3a7be9 authored by Lynn Garren's avatar Lynn Garren

use unique stream names in Random/test and allow for dependencies between tests

parent 9e33b998
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>
......
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
......
......@@ -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} )
......
......@@ -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 \
......
......@@ -198,13 +198,13 @@ int anonymousRestoreStatics1() {
HepRandom::setTheEngine(e);
randomizeStatics(15);
output << "\nRandomized, 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 << "\nRandomized, 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";
......
......@@ -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.save1"); 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.save2"); 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.save1"); is >> e >> d2;}
{ std::ifstream is ("instance_distribution.save"); is >> e >> d2;}
double k1 = d2();
double k2 = d2();
{ std::ifstream is ("distribution.save2"); 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.save1"); 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.save2"); 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.save1"); is >> e >> d2;}
{ std::ifstream is ("instance_distribution.save"); is >> e >> d2;}
double k1 = d2();
double k2 = d2();
{ std::ifstream is ("distribution.save2"); is >> e >> d2;}
{ std::ifstream is ("instance2_distribution.save"); is >> e >> d2;}
double k3 = d2();
double k4 = d2();
#ifdef VERBOSER
......
......@@ -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.save1"); 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.save2"); 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.save1"); 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.save2"); is >> e >> d1r >> d2r;}
{ std::ifstream is ("t2_shared.save"); is >> e >> d1r >> d2r;}
double k13 = d1r();
double k23 = d2r();
double k14 = d1r();
......
......@@ -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.save1");
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.save1");
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.save2");
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.save2");
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.save1");
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.save1");
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.save2");
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.save2");
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";
......
# 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 )
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