42 #ifdef GECODE_HAS_MTRACE
64 : _name(s), _next(_tests) {
65 _tests =
this; _n_tests++;
68 Base* Base::_tests = NULL;
69 unsigned int Base::_n_tests = 0;
84 for (
Base*
t = _tests;
t != NULL;
t =
t->next())
90 for ( ; i < _n_tests; i++) {
91 b[
i]->
next(_tests); _tests = b[
i];
104 std::cout <<
"Options: -seed " <<
opt.
seed;
107 std::cout <<
" -test " << name << std::endl;
109 std::cout <<
olog.str();
112 std::vector<std::pair<bool, const char*> >
testpat;
120 if (!strcmp(argv[i],
"-help") || !strcmp(argv[i],
"--help")) {
121 std::cerr <<
"Options for testing:" << std::endl
122 <<
"\t-seed (unsigned int or \"time\") default: "
124 <<
"\t\tseed for random number generator (unsigned int),"
126 <<
"\t\tor \"time\" for a random seed based on "
127 <<
"current time" << std::endl
128 <<
"\t-fixprob (unsigned int) default: "
130 <<
"\t\t1/fixprob is the probability of computing a fixpoint"
132 <<
"\t-iter (unsigned int) default: " <<
iter<< std::endl
133 <<
"\t\tthe number of iterations" << std::endl
134 <<
"\t-test (string) default: (none)" << std::endl
135 <<
"\t\tsimple pattern for the tests to run" << std::endl
136 <<
"\t\tprefixing the pattern with \"-\" negates the pattern"
138 <<
"\t\tmultiple pattern-options may be given" << std::endl
139 <<
"\t-start (string) default: (none)" << std::endl
140 <<
"\t\tsimple pattern for the first test to run" << std::endl
143 <<
"\t\tlog execution of tests"
145 <<
"\t\tthe optional argument determines the style of the log"
147 <<
"\t\twith text as the default style"
149 <<
"\t-stop (boolean) default: "
150 << (
stop ?
"true" :
"false") << std::endl
151 <<
"\t\tstop on first error or continue" << std::endl
152 <<
"\t-list" << std::endl
153 <<
"\t\toutput list of all test cases and exit" << std::endl
156 }
else if (!strcmp(argv[i],
"-seed")) {
157 if (++i == argc)
goto missing;
158 if (!strcmp(argv[i],
"time")) {
159 seed =
static_cast<unsigned int>(time(NULL));
161 seed =
static_cast<unsigned int>(atoi(argv[i]));
163 }
else if (!strcmp(argv[i],
"-iter")) {
164 if (++i == argc)
goto missing;
165 iter =
static_cast<unsigned int>(atoi(argv[i]));
166 }
else if (!strcmp(argv[i],
"-fixprob")) {
167 if (++i == argc)
goto missing;
168 fixprob =
static_cast<unsigned int>(atoi(argv[i]));
169 }
else if (!strcmp(argv[i],
"-test")) {
170 if (++i == argc)
goto missing;
171 if (argv[i][0] ==
'-')
172 testpat.push_back(std::make_pair(
true, argv[i] + 1));
174 testpat.push_back(std::make_pair(
false, argv[i]));
175 }
else if (!strcmp(argv[i],
"-start")) {
176 if (++i == argc)
goto missing;
178 }
else if (!strcmp(argv[i],
"-log")) {
180 }
else if (!strcmp(argv[i],
"-stop")) {
181 if (++i == argc)
goto missing;
182 if(argv[i][0] ==
't') {
184 }
else if (argv[i][0] ==
'f') {
187 }
else if (!strcmp(argv[i],
"-list")) {
194 std::cerr <<
"Erroneous argument (" << argv[i-1] <<
")" << std::endl
195 <<
" missing parameter" << std::endl;
203 using namespace Test;
204 #ifdef GECODE_HAS_MTRACE
214 std::cout <<
t->name() << std::endl;
221 bool started =
startFrom == NULL ?
true :
false;
226 if (
t->name().find(
startFrom) != std::string::npos)
232 bool match_found =
false;
233 bool some_positive =
false;
234 for (
unsigned int i = 0;
i <
testpat.size(); ++
i) {
236 if (
t->name().find(
testpat[
i].second) != std::string::npos)
239 some_positive =
true;
240 if (
t->name().find(
testpat[
i].second) != std::string::npos)
244 if (some_positive && !match_found)
goto next;
246 std::cout <<
t->name() <<
" ";
254 std::cout <<
"-" << std::endl;
260 std::cout << std::endl;
262 std::cout <<
"Exception in \"Gecode::" << e.
what()
264 <<
"Stopping..." << std::endl;
276 for (
int j=i.
l; j--; )