Commit 088b42c9 authored by EXT Iulian Ober's avatar EXT Iulian Ober
Browse files

added options to stop exploration after n states/seconds and limit number of generated scenarios

parent 581111a2
......@@ -60,6 +60,9 @@
// global options
int opt_qxml = 0;
int opt_txml = 0;
int opt_limit_time = -1;
int opt_limit_states = -1;
int opt_limit_scn = -1;
/*
*
......@@ -301,6 +304,17 @@ void IfExplorator::alarm() {
#endif
m_time++;
status();
if(opt_limit_time > 0 && opt_limit_time <= m_time) {
fprintf(stderr, "\ntime limit reached\n");
fflush(stderr);
exit(10);
}
if(opt_limit_states > 0 && opt_limit_states <= q_count) {
fprintf(stderr, "\nstate limit reached\n");
fflush(stderr);
exit(11);
}
}
/*
......@@ -575,15 +589,20 @@ void IfDfsExplorator::status() const {
}
void IfDfsExplorator::visit(const IfConfig* source) {
static int errorScnCnt = 0;
static int successScnCnt = 0;
IfExplorator::visit(source);
if(opt_limit_scn > 0 && (errorScnCnt+successScnCnt)>=opt_limit_scn)
return;
if (((m_flags & MS) && source->isObsSuccess()) ||
((m_flags & ME) && source->isObsError())) {
static int errorScnCnt = 1;
static int successScnCnt = 1;
char fileName[64];
if ( source->isObsSuccess() ) sprintf(fileName, "s%d.scn", successScnCnt++);
if ( source->isObsError() ) sprintf(fileName, "e%d.scn", errorScnCnt++);
if ( source->isObsSuccess() ) sprintf(fileName, "s%d.scn", ++successScnCnt);
if ( source->isObsError() ) sprintf(fileName, "e%d.scn", ++errorScnCnt);
std::ofstream file(fileName);
file << "<scenario>";
......@@ -1158,6 +1177,8 @@ int main(int argc, char* argv[]) {
[-discard] : discard unconsumed/unsaved messages in stable states \n\
[-tf] : time transition optimisation filter \n\
[-npf] : do not use dynamic priority functions \n\
[-ls integer] : exploration stops when number of states is above this limit (tested every 1s) \n\
[-lt integer] : exploration stops when time in seconds is reached \n\
.observer options \n\
[-cs|-ce] : cut on observer success|error \n\
[-ms] [-me] : mark transitions entering success/error states \n\
......@@ -1165,6 +1186,7 @@ int main(int argc, char* argv[]) {
.output options: \n\
[[-q | -qxml] filename] : output states in <filename> \n\
[[-t | -txml] filename] : output transitions in <filename> \n\
[-ld integer] : limit number of error/success scenarios that are dumped\n\
[-ln] : generate source line number info \n\
[-sp] : split transitions in individual events \n\
[-filter|-show [nsriocfktdmA]] \n\
......@@ -1280,7 +1302,22 @@ int main(int argc, char* argv[]) {
}
}
}
else {
else if (!strcmp(argv[i], "-ls")) {
if(i+1 >= argc || 0==sscanf(argv[i+1],"%d",&opt_limit_states)) {
fprintf(stderr, "option %s not followed by an integer\n", argv[i]);
return 1;
}
} else if (!strcmp(argv[i], "-lt")) {
if(i+1 >= argc || 0==sscanf(argv[i+1],"%d",&opt_limit_time)) {
fprintf(stderr, "option %s not followed by an integer\n", argv[i]);
return 1;
}
} else if (!strcmp(argv[i], "-ld")) {
if(i+1 >= argc || 0==sscanf(argv[i+1],"%d",&opt_limit_scn)) {
fprintf(stderr, "option %s not followed by an integer\n", argv[i]);
return 1;
}
} else {
fprintf(stderr, "unknown option %s\n", argv[i]);
return 1;
}
......
Supports Markdown
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