| 104 | } |
| 105 | |
| 106 | void |
| 107 | Options::parse(int argc, char* argv[]) { |
| 108 | int i = 1; |
| 109 | while (i < argc) { |
| 110 | if (!strcmp(argv[i],"-help") || !strcmp(argv[i],"--help")) { |
| 111 | std::cerr << "Options for testing:" << std::endl |
| 112 | << "\t-threads (unsigned int) default: " << threads << std::endl |
| 113 | << "\t\tnumber of threads to use. If 0, as many threads as there are cores are used.\n" |
| 114 | << "\t\tThreaded execution and logging can not be used at the same time." |
| 115 | << std::endl |
| 116 | << "\t-seed (unsigned int or \"time\") default: " |
| 117 | << seed << std::endl |
| 118 | << "\t\tseed for random number generator (unsigned int)," |
| 119 | << std::endl |
| 120 | << "\t\tor \"time\" for a random seed based on " |
| 121 | << "current time" << std::endl |
| 122 | << "\t-fixprob (unsigned int) default: " |
| 123 | << fixprob << std::endl |
| 124 | << "\t\t1/fixprob is the probability of computing a fixpoint" |
| 125 | << std::endl |
| 126 | << "\t-iter (unsigned int) default: " <<iter<< std::endl |
| 127 | << "\t\tthe number of iterations" << std::endl |
| 128 | << "\t-test (string) default: (none)" << std::endl |
| 129 | << "\t\tsimple pattern for the tests to run" << std::endl |
| 130 | << "\t\tprefixing with \"-\" negates the pattern" << std::endl |
| 131 | << "\t\tprefixing with \"^\" requires a match at the beginning" << std::endl |
| 132 | << "\t\tmultiple pattern-options may be given" |
| 133 | << std::endl |
| 134 | << "\t-start (string) default: (none)" << std::endl |
| 135 | << "\t\tsimple pattern for the first test to run" << std::endl |
| 136 | << "\t-log" |
| 137 | << std::endl |
| 138 | << "\t\tlog execution of tests" |
| 139 | << std::endl |
| 140 | << "\t\tthe optional argument determines the style of the log" |
| 141 | << std::endl |
| 142 | << "\t\twith text as the default style" |
| 143 | << std::endl |
| 144 | << "\t-stop (boolean) default: " |
| 145 | << (stop ? "true" : "false") << std::endl |
| 146 | << "\t\tstop on first error or continue" << std::endl |
| 147 | << "\t-list" << std::endl |
| 148 | << "\t\toutput list of all test cases and exit" << std::endl |
| 149 | ; |
| 150 | exit(EXIT_SUCCESS); |
| 151 | } else if (!strcmp(argv[i],"-threads")) { |
| 152 | if (++i == argc) goto missing; |
| 153 | unsigned int argument = static_cast<unsigned int>(atoi(argv[i])); |
| 154 | if (argument == 0) { |
| 155 | threads = Gecode::Support::Thread::npu(); |
| 156 | } else { |
| 157 | threads = argument; |
| 158 | } |
| 159 | } else if (!strcmp(argv[i],"-seed")) { |
| 160 | if (++i == argc) goto missing; |
| 161 | if (!strcmp(argv[i],"time")) { |
| 162 | seed = static_cast<unsigned int>(time(nullptr)); |
| 163 | } else { |