diff options
author | Aaron <aaron@10gen.com> | 2009-01-17 10:25:56 -0500 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-01-17 10:25:56 -0500 |
commit | 57b78fd14478a5b1567fede1e9f2de8a712d8d04 (patch) | |
tree | 07df6998d87f34031ac80e32b07aee1782aec032 /dbtests | |
parent | 4097bfec55e8ed7aa6683344feadb2933adc2439 (diff) | |
download | mongo-57b78fd14478a5b1567fede1e9f2de8a712d8d04.tar.gz |
Allow random seed spec
Diffstat (limited to 'dbtests')
-rw-r--r-- | dbtests/dbtests.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp index 4288622b6ee..0241a5f3857 100644 --- a/dbtests/dbtests.cpp +++ b/dbtests/dbtests.cpp @@ -38,12 +38,15 @@ void usage() { " (default is /tmp/unittest/)\n" " -debug run tests with verbose output\n" " -list list available test suites\n" + " -seed <seed> random number seed\n" " <suite> run the specified test suite only"; out() << instructions << endl; } int main( int argc, char** argv ) { + unsigned long long seed = time( 0 ); + int offset = 0; for ( int i = 1; i < argc; ++i ) { if ( argv[ i ] == string( "-dbpath" ) ) { @@ -53,6 +56,14 @@ int main( int argc, char** argv ) { } dbpathSpec = argv[ ++i ]; offset += 2; + } else if ( argv[ i ] == string( "-seed" ) ) { + if ( i == argc - 1 ) { + usage(); + exit( -1 ); + } + // Don't bother checking for conversion error + seed = strtoll( argv[ ++i ], 0, 10 ); + offset += 2; } else if ( argv[ i ] == string( "-help" ) ) { usage(); exit( 0 ); @@ -66,11 +77,8 @@ int main( int argc, char** argv ) { dbpathSpec += "/"; dbpath = dbpathSpec.c_str(); - time_t seed = time( 0 ); srand( seed ); - stringstream ss; - ss << "random seed: " << seed; - out() << ss.str() << endl; + out() << "random seed: " << seed << endl; UnitTest::Registry tests; |