Merge pull request #195 from jschwartz-cray/fix-194

Fix #194.
master
Julian Kunkel 2020-06-24 09:43:56 +01:00 committed by GitHub
commit 8faa6c88d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 104 deletions

View File

@ -210,7 +210,7 @@ void PrintRepeatStart(){
} }
void PrintTestEnds(){ void PrintTestEnds(){
if (rank != 0 || verbose < VERBOSE_0) { if (rank != 0 || verbose <= VERBOSE_0) {
PrintEndSection(); PrintEndSection();
return; return;
} }
@ -441,6 +441,10 @@ void ShowSetup(IOR_param_t *params)
if(params->dryRun){ if(params->dryRun){
PrintKeyValInt("dryRun", params->dryRun); PrintKeyValInt("dryRun", params->dryRun);
} }
if(params->verbose) {
PrintKeyValInt("verbose", params->verbose);
}
if (params->deadlineForStonewalling > 0) { if (params->deadlineForStonewalling > 0) {
PrintKeyValInt("stonewallingTime", params->deadlineForStonewalling); PrintKeyValInt("stonewallingTime", params->deadlineForStonewalling);
PrintKeyValInt("stoneWallingWearOut", params->stoneWallingWearOut ); PrintKeyValInt("stoneWallingWearOut", params->stoneWallingWearOut );
@ -516,7 +520,7 @@ static void PrintLongSummaryOneOperation(IOR_test_t *test, const int access)
struct results *ops; struct results *ops;
int reps; int reps;
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose <= VERBOSE_0)
return; return;
reps = params->repetitions; reps = params->repetitions;
@ -631,7 +635,7 @@ void PrintLongSummaryOneTest(IOR_test_t *test)
void PrintLongSummaryHeader() void PrintLongSummaryHeader()
{ {
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose <= VERBOSE_0)
return; return;
if(outputFormat != OUTPUT_DEFAULT){ if(outputFormat != OUTPUT_DEFAULT){
return; return;
@ -651,7 +655,7 @@ void PrintLongSummaryHeader()
void PrintLongSummaryAllTests(IOR_test_t *tests_head) void PrintLongSummaryAllTests(IOR_test_t *tests_head)
{ {
IOR_test_t *tptr; IOR_test_t *tptr;
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose <= VERBOSE_0)
return; return;
PrintArrayEnd(); PrintArrayEnd();
@ -684,7 +688,7 @@ void PrintShortSummary(IOR_test_t * test)
int reps; int reps;
int i; int i;
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose <= VERBOSE_0)
return; return;
PrintArrayEnd(); PrintArrayEnd();
@ -723,7 +727,7 @@ void PrintShortSummary(IOR_test_t * test)
void PrintRemoveTiming(double start, double finish, int rep) void PrintRemoveTiming(double start, double finish, int rep)
{ {
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose <= VERBOSE_0)
return; return;
if (outputFormat == OUTPUT_DEFAULT){ if (outputFormat == OUTPUT_DEFAULT){

View File

@ -180,9 +180,9 @@ int ior_main(int argc, char **argv)
test_finalize(tptr); test_finalize(tptr);
} }
if (verbose < 0) if (verbose <= VERBOSE_0)
/* always print final summary */ /* always print final summary */
verbose = 0; verbose = VERBOSE_1;
PrintLongSummaryAllTests(tests_head); PrintLongSummaryAllTests(tests_head);
/* display finish time */ /* display finish time */
@ -1276,7 +1276,7 @@ static void TestIoSys(IOR_test_t *test)
return; return;
} }
if (rank == 0 && verbose >= VERBOSE_1) { if (rank == 0 && verbose >= VERBOSE_1) {
fprintf(out_logfile, "Participating tasks: %d\n", params->numTasks); fprintf(out_logfile, "Participating tasks : %d\n", params->numTasks);
fflush(out_logfile); fflush(out_logfile);
} }
if (rank == 0 && params->reorderTasks == TRUE && verbose >= VERBOSE_1) { if (rank == 0 && params->reorderTasks == TRUE && verbose >= VERBOSE_1) {
@ -1316,13 +1316,13 @@ static void TestIoSys(IOR_test_t *test)
ERR("cannot get current time"); ERR("cannot get current time");
} }
params->timeStampSignatureValue = params->timeStampSignatureValue =
(unsigned int) currentTime; (unsigned int)currentTime;
if (verbose >= VERBOSE_2) { }
fprintf(out_logfile, if (verbose >= VERBOSE_2) {
"Using Time Stamp %u (0x%x) for Data Signature\n", fprintf(out_logfile,
params->timeStampSignatureValue, "Using Time Stamp %u (0x%x) for Data Signature\n",
params->timeStampSignatureValue); params->timeStampSignatureValue,
} params->timeStampSignatureValue);
} }
if (rep == 0 && verbose >= VERBOSE_0) { if (rep == 0 && verbose >= VERBOSE_0) {
PrintTableHeader(); PrintTableHeader();

View File

@ -241,110 +241,125 @@ static void option_parse_token(char ** argv, int * flag_parsed_next, int * requi
} }
*flag_parsed_next = 0; *flag_parsed_next = 0;
for(int m = 0; m < opt_all->module_count; m++ ){ // just skip over the first dash so we don't have to handle it everywhere below
option_help * args = opt_all->modules[m].options; if(txt[0] != '-'){
if(args == NULL) continue; *error = 1;
// try to find matching option help return;
for(option_help * o = args; o->shortVar != 0 || o->longVar != 0 || o->help != NULL ; o++ ){ }
if( o->shortVar == 0 && o->longVar == 0 ){ txt++;
// section
continue; // support groups of multiple flags like -vvv or -vq
} for(int flag_index = 0; flag_index < strlen(txt); ++flag_index){
if ( (txt[0] == '-' && o->shortVar == txt[1]) || (strlen(txt) > 2 && txt[0] == '-' && txt[1] == '-' && o->longVar != NULL && strcmp(txt + 2, o->longVar) == 0)){ // don't loop looking for multiple flags if we already processed a long option
// now process the option. if(txt[0] == '-' && flag_index > 0)
switch(o->arg){ break;
case (OPTION_FLAG):{
assert(o->type == 'd'); for(int m = 0; m < opt_all->module_count; m++ ){
if(arg != NULL){ option_help * args = opt_all->modules[m].options;
int val = atoi(arg); if(args == NULL) continue;
(*(int*) o->variable) = (val < 0) ? 0 : val; // try to find matching option help
}else{ for(option_help * o = args; o->shortVar != 0 || o->longVar != 0 || o->help != NULL ; o++ ){
(*(int*) o->variable)++; if( o->shortVar == 0 && o->longVar == 0 ){
} // section
break; continue;
} }
case (OPTION_OPTIONAL_ARGUMENT): if ( (o->shortVar == txt[flag_index]) || (strlen(txt) > 2 && txt[0] == '-' && o->longVar != NULL && strcmp(txt + 1, o->longVar) == 0)){
case (OPTION_REQUIRED_ARGUMENT):{ // now process the option.
// check if next is an argument switch(o->arg){
if(arg == NULL){ case (OPTION_FLAG):{
if(o->shortVar == txt[1] && txt[2] != 0){ assert(o->type == 'd');
arg = & txt[2]; if(arg != NULL){
int val = atoi(arg);
(*(int*) o->variable) = (val < 0) ? 0 : val;
}else{ }else{
// simply take the next value as argument (*(int*) o->variable)++;
i++;
arg = argv[1];
*flag_parsed_next = 1;
} }
break;
} }
case (OPTION_OPTIONAL_ARGUMENT):
if(arg == NULL){ case (OPTION_REQUIRED_ARGUMENT):{
const char str[] = {o->shortVar, 0}; // check if next is an argument
printf("Error, argument missing for option %s\n", (o->longVar != NULL) ? o->longVar : str); if(arg == NULL){
exit(1); if(o->shortVar == txt[0] && txt[1] != 0){
} arg = & txt[1];
}else{
switch(o->type){ // simply take the next value as argument
case('p'):{ i++;
// call the function in the variable arg = argv[1];
void(*fp)() = o->variable; *flag_parsed_next = 1;
fp(arg);
break;
}
case('F'):{
*(double*) o->variable = atof(arg);
break;
}
case('f'):{
*(float*) o->variable = atof(arg);
break;
}
case('d'):{
int64_t val = string_to_bytes(arg);
if (val > INT_MAX || val < INT_MIN){
printf("WARNING: parsing the number %s to integer, this produced an overflow!\n", arg);
} }
*(int*) o->variable = val;
break;
} }
case('H'):
case('s'):{ if(arg == NULL){
(*(char **) o->variable) = strdup(arg); const char str[] = {o->shortVar, 0};
break; printf("Error, argument missing for option %s\n", (o->longVar != NULL) ? o->longVar : str);
exit(1);
} }
case('c'):{
(*(char *)o->variable) = arg[0]; switch(o->type){
if(strlen(arg) > 1){ case('p'):{
printf("Error, ignoring remainder of string for option %c (%s).\n", o->shortVar, o->longVar); // call the function in the variable
void(*fp)() = o->variable;
fp(arg);
break;
} }
break; case('F'):{
} *(double*) o->variable = atof(arg);
case('l'):{ break;
*(long long*) o->variable = string_to_bytes(arg); }
break; case('f'):{
} *(float*) o->variable = atof(arg);
case('u'):{ break;
*(uint64_t*) o->variable = string_to_bytes(arg); }
break; case('d'):{
int64_t val = string_to_bytes(arg);
if (val > INT_MAX || val < INT_MIN){
printf("WARNING: parsing the number %s to integer, this produced an overflow!\n", arg);
}
*(int*) o->variable = val;
break;
}
case('H'):
case('s'):{
(*(char **) o->variable) = strdup(arg);
break;
}
case('c'):{
(*(char *)o->variable) = arg[0];
if(strlen(arg) > 1){
printf("Error, ignoring remainder of string for option %c (%s).\n", o->shortVar, o->longVar);
}
break;
}
case('l'):{
*(long long*) o->variable = string_to_bytes(arg);
break;
}
case('u'):{
*(uint64_t*) o->variable = string_to_bytes(arg);
break;
}
default:
printf("ERROR: Unknown option type %c\n", o->type);
break;
} }
default:
printf("ERROR: Unknown option type %c\n", o->type);
} }
} }
} if(replaced_equal){
if(replaced_equal){ arg[-1] = '=';
arg[-1] = '='; }
}
if(o->arg == OPTION_REQUIRED_ARGUMENT){ if(o->arg == OPTION_REQUIRED_ARGUMENT){
(*requiredArgsSeen)++; (*requiredArgsSeen)++;
} }
return; return;
}
} }
} }
} }
if(strcmp(txt, "-h") == 0 || strcmp(txt, "--help") == 0){ if(strcmp(txt, "h") == 0 || strcmp(txt, "-help") == 0){
*print_help = 1; *print_help = 1;
}else{ }else{
*error = 1; *error = 1;