Fix #194.
On previous versions of IOR (and most Linux CLI applications in general) multiple flags can be combined such as -vvv to get verbose=3 rather than having to specify each separately as -v -v -v. This patch fixes this behavior. It also fixes issues around handling of the verbose flag where the output would never be printed as we were comparing verbose < VERBOSE_0 where verbose defaults to 0 and can only increase.master
parent
0d9f46e980
commit
61333af822
|
@ -210,7 +210,7 @@ void PrintRepeatStart(){
|
|||
}
|
||||
|
||||
void PrintTestEnds(){
|
||||
if (rank != 0 || verbose < VERBOSE_0) {
|
||||
if (rank != 0 || verbose <= VERBOSE_0) {
|
||||
PrintEndSection();
|
||||
return;
|
||||
}
|
||||
|
@ -445,6 +445,9 @@ void ShowSetup(IOR_param_t *params)
|
|||
if(params->dryRun){
|
||||
PrintKeyValInt("dryRun", params->dryRun);
|
||||
}
|
||||
if(params->verbose) {
|
||||
PrintKeyValInt("verbose", params->verbose);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
|
||||
if (params->lustre_set_striping) {
|
||||
|
@ -528,7 +531,7 @@ static void PrintLongSummaryOneOperation(IOR_test_t *test, const int access)
|
|||
struct results *ops;
|
||||
|
||||
int reps;
|
||||
if (rank != 0 || verbose < VERBOSE_0)
|
||||
if (rank != 0 || verbose <= VERBOSE_0)
|
||||
return;
|
||||
|
||||
reps = params->repetitions;
|
||||
|
@ -643,7 +646,7 @@ void PrintLongSummaryOneTest(IOR_test_t *test)
|
|||
|
||||
void PrintLongSummaryHeader()
|
||||
{
|
||||
if (rank != 0 || verbose < VERBOSE_0)
|
||||
if (rank != 0 || verbose <= VERBOSE_0)
|
||||
return;
|
||||
if(outputFormat != OUTPUT_DEFAULT){
|
||||
return;
|
||||
|
@ -663,7 +666,7 @@ void PrintLongSummaryHeader()
|
|||
void PrintLongSummaryAllTests(IOR_test_t *tests_head)
|
||||
{
|
||||
IOR_test_t *tptr;
|
||||
if (rank != 0 || verbose < VERBOSE_0)
|
||||
if (rank != 0 || verbose <= VERBOSE_0)
|
||||
return;
|
||||
|
||||
PrintArrayEnd();
|
||||
|
@ -696,7 +699,7 @@ void PrintShortSummary(IOR_test_t * test)
|
|||
int reps;
|
||||
int i;
|
||||
|
||||
if (rank != 0 || verbose < VERBOSE_0)
|
||||
if (rank != 0 || verbose <= VERBOSE_0)
|
||||
return;
|
||||
|
||||
PrintArrayEnd();
|
||||
|
@ -767,7 +770,7 @@ void DisplayFreespace(IOR_param_t * test)
|
|||
|
||||
void PrintRemoveTiming(double start, double finish, int rep)
|
||||
{
|
||||
if (rank != 0 || verbose < VERBOSE_0)
|
||||
if (rank != 0 || verbose <= VERBOSE_0)
|
||||
return;
|
||||
|
||||
if (outputFormat == OUTPUT_DEFAULT){
|
||||
|
|
|
@ -147,9 +147,9 @@ int ior_main(int argc, char **argv)
|
|||
ShowTestEnd(tptr);
|
||||
}
|
||||
|
||||
if (verbose < 0)
|
||||
if (verbose <= VERBOSE_0)
|
||||
/* always print final summary */
|
||||
verbose = 0;
|
||||
verbose = VERBOSE_1;
|
||||
PrintLongSummaryAllTests(tests_head);
|
||||
|
||||
/* display finish time */
|
||||
|
@ -1261,13 +1261,13 @@ static void TestIoSys(IOR_test_t *test)
|
|||
}
|
||||
params->timeStampSignatureValue =
|
||||
(unsigned int)currentTime;
|
||||
}
|
||||
if (verbose >= VERBOSE_2) {
|
||||
fprintf(out_logfile,
|
||||
"Using Time Stamp %u (0x%x) for Data Signature\n",
|
||||
params->timeStampSignatureValue,
|
||||
params->timeStampSignatureValue);
|
||||
}
|
||||
}
|
||||
if (rep == 0 && verbose >= VERBOSE_0) {
|
||||
PrintTableHeader();
|
||||
}
|
||||
|
|
22
src/option.c
22
src/option.c
|
@ -233,6 +233,19 @@ static void option_parse_token(char ** argv, int * flag_parsed_next, int * requi
|
|||
}
|
||||
*flag_parsed_next = 0;
|
||||
|
||||
// just skip over the first dash so we don't have to handle it everywhere below
|
||||
if(txt[0] != '-'){
|
||||
*error = 1;
|
||||
return;
|
||||
}
|
||||
txt++;
|
||||
|
||||
// support groups of multiple flags like -vvv or -vq
|
||||
for(int flag_index = 0; flag_index < strlen(txt); ++flag_index){
|
||||
// don't loop looking for multiple flags if we already processed a long option
|
||||
if(txt[0] == '-' && flag_index > 0)
|
||||
break;
|
||||
|
||||
for(int m = 0; m < opt_all->module_count; m++ ){
|
||||
option_help * args = opt_all->modules[m].options;
|
||||
if(args == NULL) continue;
|
||||
|
@ -242,7 +255,7 @@ static void option_parse_token(char ** argv, int * flag_parsed_next, int * requi
|
|||
// section
|
||||
continue;
|
||||
}
|
||||
if ( (txt[0] == '-' && o->shortVar == txt[1]) || (strlen(txt) > 2 && txt[0] == '-' && txt[1] == '-' && o->longVar != NULL && strcmp(txt + 2, o->longVar) == 0)){
|
||||
if ( (o->shortVar == txt[flag_index]) || (strlen(txt) > 2 && txt[0] == '-' && o->longVar != NULL && strcmp(txt + 1, o->longVar) == 0)){
|
||||
// now process the option.
|
||||
switch(o->arg){
|
||||
case (OPTION_FLAG):{
|
||||
|
@ -259,8 +272,8 @@ static void option_parse_token(char ** argv, int * flag_parsed_next, int * requi
|
|||
case (OPTION_REQUIRED_ARGUMENT):{
|
||||
// check if next is an argument
|
||||
if(arg == NULL){
|
||||
if(o->shortVar == txt[1] && txt[2] != 0){
|
||||
arg = & txt[2];
|
||||
if(o->shortVar == txt[0] && txt[1] != 0){
|
||||
arg = & txt[1];
|
||||
}else{
|
||||
// simply take the next value as argument
|
||||
i++;
|
||||
|
@ -331,8 +344,9 @@ static void option_parse_token(char ** argv, int * flag_parsed_next, int * requi
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(txt, "-h") == 0 || strcmp(txt, "--help") == 0){
|
||||
if(strcmp(txt, "h") == 0 || strcmp(txt, "-help") == 0){
|
||||
*print_help = 1;
|
||||
}else{
|
||||
*error = 1;
|
||||
|
|
Loading…
Reference in New Issue