示例#1
0
/*
 * parse the command line options
 */
static int
parse_options(int argc, char **argv)
{
    while (--argc){
  if (**(++argv) != '-'){
      break;
  }else{
      switch(*(*argv+1)){
    case 'v':   if (*((*argv+1)+1))
        ParseTestVerbosity((*argv+1)+1);
          else
        SetTestVerbosity(VERBO_MED);
          break;
    case 'f':   if (--argc < 1) {
        nerrors++;
        return(1);
          }
          if (**(++argv) == '-') {
        nerrors++;
        return(1);
          }
          paraprefix = *argv;
          break;
    case 'h':   /* print help message--return with nerrors set */
          return(1);
    default:    nerrors++;
          return(1);
      }
  }
    } /*while*/

    /* compose the test filenames */
    {
  int i, n;
  hid_t plist;

  plist = H5Pcreate (H5P_FILE_ACCESS);
  H5Pset_fapl_mpio(plist, MPI_COMM_WORLD, MPI_INFO_NULL);
  n = sizeof(FILENAME)/sizeof(FILENAME[0]) - 1;  /* exclude the NULL */

  for (i=0; i < n; i++)
      if (h5_fixname(FILENAME[i],plist,filenames[i],sizeof(filenames[i]))
    == NULL){
    printf("h5_fixname failed\n");
    nerrors++;
    return(1);
      }
  H5Pclose(plist);
  if (VERBOSE_MED){
      printf("Test filenames are:\n");
      for (i=0; i < n; i++)
    printf("    %s\n", filenames[i]);
  }
    }

    return(0);
}
/*
 * Parse command line information.
 *      argc, argv: the usual command line argument count and strings
 *
 * Return: Void
 *    exit EXIT_FAILURE if error is encountered.
 *
 * Modification:
 * 	2004/08/18 Albert Cheng.  Add extra_parse feature.
 */
void TestParseCmdLine(int argc, char *argv[])
{
    int ret_code;

    while (argv++, --argc > 0){
	if ((HDstrcmp(*argv, "-verbose") == 0) ||
				(HDstrcmp(*argv, "-v") == 0)) {
	    if (argc > 0){
		--argc; ++argv;
		ParseTestVerbosity(*argv);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-exclude") == 0) ||
				    (HDstrcmp(*argv, "-x") == 0))) {
	    if (argc > 0){
		--argc; ++argv;
		SetTest(*argv, SKIPTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-begin") == 0) ||
				    (HDstrcmp(*argv, "-b") == 0))) {
	    if (argc > 0){
		--argc; ++argv;
		SetTest(*argv, BEGINTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-only") == 0) ||
				    (HDstrcmp(*argv, "-o") == 0))) {
	    if (argc > 0){
		int Loop;
		--argc; ++argv;
		/* Skip all tests, then activate only one. */
		for (Loop = 0; Loop < Index; Loop++)
		    Test[Loop].SkipFlag = 1;
		SetTest(*argv, ONLYTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0))
            Summary = 1;
	else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) {
            TestUsage();
            exit(EXIT_SUCCESS);
        }
	else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0))
	    SetTestNoCleanup();
	else {
	    /* non-standard option.  Break out. */
	    break;
	}

    }

    /* Call extra parsing function if provided. */
    if (NULL != TestPrivateParser){
	ret_code=TestPrivateParser(argc+1, argv-1);
	if (ret_code != 0)
	    exit(EXIT_FAILURE);
    }
}