00001 00004 /* Copyright (C) 2010 Richard Boulton 00005 * Copyright (C) 2011 Olly Betts 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00020 * USA 00021 */ 00022 00023 #include <config.h> 00024 00025 #include "soaktest/soaktest.h" 00026 00027 #include "soaktest/soaktest_all.h" 00028 #include "testrunner.h" 00029 #include "testsuite.h" 00030 00031 // random() and srandom() aren't in <cstdlib> with Sun's compiler. 00032 #include <stdlib.h> 00033 00034 using namespace std; 00035 00036 unsigned int g_random_seed; 00037 00038 extern unsigned int initrand() 00039 { 00040 tout << "Setting random seed to " << g_random_seed << "\n"; 00041 srandom(g_random_seed); 00042 return g_random_seed; 00043 } 00044 00045 extern unsigned int randint(unsigned int s) 00046 { 00047 unsigned long int r = static_cast<unsigned long int>(random()); 00048 r = r % static_cast<unsigned long int>(s); 00049 return static_cast<unsigned int>(r); 00050 } 00051 00052 class SoakTestRunner : public TestRunner 00053 { 00054 string seed_str; 00055 public: 00056 SoakTestRunner() : seed_str("42") { 00057 test_driver::add_command_line_option("seed", 's', &seed_str); 00058 } 00059 00060 int run() const { 00061 int result = 0; 00062 g_random_seed = atoi(seed_str.c_str()); 00063 #include "soaktest/soaktest_collated.h" 00064 return result; 00065 } 00066 }; 00067 00068 int main(int argc, char **argv) 00069 { 00070 SoakTestRunner runner; 00071 return runner.run_tests(argc, argv); 00072 }