/* * Read the configuration script, allocating and filling in the structure of * global parameters. */ IOR_test_t *ReadConfigScript(char *scriptName) { int test_num = 0; int runflag = 0; char linebuf[MAX_STR]; char empty[MAX_STR]; FILE *file; IOR_test_t *head = NULL; IOR_test_t *tail = NULL; IOR_test_t *newTest = NULL; /* Initialize the first test */ head = CreateTest(&initialTestParams, test_num++); tail = head; /* open the script */ file = fopen(scriptName, "r"); if (file == NULL) ERR("fopen() failed"); /* search for the "IOR START" line */ while (fgets(linebuf, MAX_STR, file) != NULL) { if (contains_only(linebuf, "ior start")) { break; } } /* Iterate over a block of IOR commands */ while (fgets(linebuf, MAX_STR, file) != NULL) { /* skip empty lines */ if (sscanf(linebuf, "%s", empty) == -1) continue; /* skip lines containing only comments */ if (sscanf(linebuf, " #%s", empty) == 1) continue; if (contains_only(linebuf, "ior stop")) { AllocResults(tail); break; } else if (contains_only(linebuf, "run")) { AllocResults(tail); runflag = 1; } else if (runflag) { /* If this directive was preceded by a "run" line, then create and initialize a new test structure */ runflag = 0; tail->next = CreateTest(&tail->params, test_num++); tail = tail->next; ParseLine(linebuf, &tail->params); } else { ParseLine(linebuf, &tail->params); } } /* close the script */ if (fclose(file) != 0) ERR("fclose() of script file failed"); return head; }
/* * Parse Commandline. */ IOR_test_t *ParseCommandLine(int argc, char **argv) { static const char *opts = "a:A:b:BcCd:D:eEf:FgG:hHi:Ij:J:kKlL:mM:nN:o:O:pPqQ:rRs:St:T:uU:vVwWxX:YzZ"; int c, i; static IOR_test_t *tests = NULL; /* suppress getopt() error message when a character is unrecognized */ opterr = 0; init_IOR_Param_t(&initialTestParams); GetPlatformName(initialTestParams.platform); initialTestParams.writeFile = initialTestParams.readFile = FALSE; initialTestParams.checkWrite = initialTestParams.checkRead = FALSE; while ((c = getopt(argc, argv, opts)) != -1) { switch (c) { case 'A': initialTestParams.referenceNumber = atoi(optarg); break; case 'a': strcpy(initialTestParams.api, optarg); break; case 'b': initialTestParams.blockSize = StringToBytes(optarg); RecalculateExpectedFileSize(&initialTestParams); break; case 'B': initialTestParams.useO_DIRECT = TRUE; break; case 'c': initialTestParams.collective = TRUE; break; case 'C': initialTestParams.reorderTasks = TRUE; break; case 'Q': initialTestParams.taskPerNodeOffset = atoi(optarg); break; case 'Z': initialTestParams.reorderTasksRandom = TRUE; break; case 'X': initialTestParams.reorderTasksRandomSeed = atoi(optarg); break; case 'd': initialTestParams.interTestDelay = atoi(optarg); break; case 'D': initialTestParams.deadlineForStonewalling = atoi(optarg); break; case 'Y': initialTestParams.fsyncPerWrite = TRUE; break; case 'e': initialTestParams.fsync = TRUE; break; case 'E': initialTestParams.useExistingTestFile = TRUE; break; case 'f': tests = ReadConfigScript(optarg); break; case 'F': initialTestParams.filePerProc = TRUE; break; case 'g': initialTestParams.intraTestBarriers = TRUE; break; case 'G': initialTestParams.setTimeStampSignature = atoi(optarg); break; case 'h': initialTestParams.showHelp = TRUE; break; case 'H': initialTestParams.showHints = TRUE; break; case 'i': initialTestParams.repetitions = atoi(optarg); break; case 'I': initialTestParams.individualDataSets = TRUE; break; case 'j': initialTestParams.outlierThreshold = atoi(optarg); break; case 'J': initialTestParams.setAlignment = StringToBytes(optarg); break; case 'k': initialTestParams.keepFile = TRUE; break; case 'K': initialTestParams.keepFileWithError = TRUE; break; case 'l': initialTestParams.storeFileOffset = TRUE; break; case 'L': initialTestParams.interOpDelay = atoi(optarg); break; case 'M': initialTestParams.memoryPerNode = NodeMemoryStringToBytes(optarg); break; case 'm': initialTestParams.multiFile = TRUE; break; case 'n': initialTestParams.noFill = TRUE; break; case 'N': initialTestParams.numTasks = atoi(optarg); RecalculateExpectedFileSize(&initialTestParams); break; case 'o': strcpy(initialTestParams.testFileName, optarg); break; case 'O': ParseLine(optarg, &initialTestParams); break; case 'p': initialTestParams.preallocate = TRUE; break; case 'P': initialTestParams.useSharedFilePointer = TRUE; break; case 'q': initialTestParams.quitOnError = TRUE; break; case 'r': initialTestParams.readFile = TRUE; break; case 'R': initialTestParams.checkRead = TRUE; break; case 's': initialTestParams.segmentCount = atoi(optarg); RecalculateExpectedFileSize(&initialTestParams); break; case 'S': initialTestParams.useStridedDatatype = TRUE; break; case 't': initialTestParams.transferSize = StringToBytes(optarg); break; case 'T': initialTestParams.maxTimeDuration = atoi(optarg); break; case 'u': initialTestParams.uniqueDir = TRUE; break; case 'U': strcpy(initialTestParams.hintsFileName, optarg); break; case 'v': initialTestParams.verbose++; break; case 'V': initialTestParams.useFileView = TRUE; break; case 'w': initialTestParams.writeFile = TRUE; break; case 'W': initialTestParams.checkWrite = TRUE; break; case 'x': initialTestParams.singleXferAttempt = TRUE; break; case 'z': initialTestParams.randomOffset = TRUE; break; default: fprintf(stdout, "ParseCommandLine: unknown option `-%c'.\n", optopt); } } for (i = optind; i < argc; i++) fprintf(stdout, "non-option argument: %s\n", argv[i]); /* If an IOR script was not used, initialize test queue to the defaults */ if (tests == NULL) { tests = CreateTest(&initialTestParams, 0); AllocResults(tests); } CheckRunSettings(tests); return (tests); }