コード例 #1
0
int main(int argc, char *argv[])
{
	const struct weston_test *t;
	int total = 0;
	int pass = 0;
	int skip = 0;

	if (argc == 2) {
		const char *testname = argv[1];
		if (strcmp(testname, "--help") == 0 ||
		    strcmp(testname, "-h") == 0) {
			fprintf(stderr, "Usage: %s [test-name]\n", program_invocation_short_name);
			list_tests();
			exit(EXIT_SUCCESS);
		}

		if (strcmp(testname, "--params") == 0 ||
		    strcmp(testname, "-p") == 0) {
			printf("%s", server_parameters);
			exit(EXIT_SUCCESS);
		}

		t = find_test(argv[1]);
		if (t == NULL) {
			fprintf(stderr, "unknown test: \"%s\"\n", argv[1]);
			list_tests();
			exit(EXIT_FAILURE);
		}

		int number_passed_in_test = 0, number_skipped_in_test = 0;
		total += iterate_test(t, &number_passed_in_test, &number_skipped_in_test);
		pass += number_passed_in_test;
		skip += number_skipped_in_test;
	} else {
		for (t = &__start_test_section; t < &__stop_test_section; t++) {
			int number_passed_in_test = 0, number_skipped_in_test = 0;
			total += iterate_test(t, &number_passed_in_test, &number_skipped_in_test);
			pass += number_passed_in_test;
			skip += number_skipped_in_test;
		}
	}

	fprintf(stderr, "%d tests, %d pass, %d skip, %d fail\n",
		total, pass, skip, total - pass - skip);

	if (skip == total)
		return SKIP;
	else if (pass + skip == total)
		return EXIT_SUCCESS;

	return EXIT_FAILURE;
}
コード例 #2
0
 Framework::ReturnCode Framework::list() const {
     std::stringstream sStr;
     ListTests list_tests;
     list_tests(sStr, get_registry()->makeTest());
     std::cout << sStr.str() << std::endl;
     return SUCCESS;
 }
コード例 #3
0
  /**
   * If you have extra command line parameters, you may use this method to start CPUnit
   * after you have done your own. You should use {@link #get_cmd_line_parser()} to obtain
   * a parser which is already set up to accept the CPUnit specific command line parameters,
   * and then use CmdLineParser.add_legal to specify the arguments you expect in addition.
   * 
   * @param parser A parser contaiing the command line arguments, excluding the program name.
   *               I.e. from main(int& argc,char** args), the parser would be called as
   *               {@link CmdLineParser#parse(const int, const char**) parser.parse(arcg-1,args+1)}.
   * @return 0 if all tests succeed, and >0 elsewise.
  */
  int main(const CmdLineParser &parser) {

    AutoDisposer ad;
    try {
      CPUNIT_ITRACE("EntryPoint - Actual arguments:"<<parser.to_string());

      std::vector<std::string> patterns = parser.program_input();
      if (patterns.size() == 0) { 
	patterns.push_back("*");
      }
      
      if(parser.has_one_of("-h --help")) {
	usage();
	return 0;
      }
      if(parser.has_one_of("-L --list")) {
	list_tests(patterns);
	return 0;
      }
      if(parser.has_one_of("-V --version")) {
	print_version_info();
	return 0;
      }
      
      const bool verbose    = parser.has("-v") || parser.has("--verbose");
      const bool robust     = parser.has("-a") || parser.has("--all");
      const bool conformity = parser.has("--conformity");
      
      CPUNIT_ITRACE("EntryPoint - verbose="<<verbose<<" robust="<<robust<<" conformity="<<conformity);
      
      bool conform = true;
      if (conformity) {
	std::vector<std::string> conf_patterns = get_conformity_format(parser);
	const int num_conformity_breaches = conformity_report(patterns, conf_patterns[0], conf_patterns[1], conf_patterns[2], verbose, std::cout);
	std::cout<<"There where "<<num_conformity_breaches<<" conformity breaches."<<std::endl;
	conform = num_conformity_breaches == 0;
      }

      const std::string report_format = parser.value_of<std::string>(error_format_token);
      const double max_time = parser.value_of<double>(max_time_token);
      const std::vector<cpunit::ExecutionReport> result = cpunit::TestExecutionFacade().execute(patterns, max_time, verbose, robust);
      bool all_well = report_result(result, report_format, std::cout);
      
      int exit_value = 0;
      if (!all_well) {
	exit_value |= 0x1;
      }
      if(!conform) {
	exit_value |= 0x2;
      }
      return exit_value;
    } catch (AssertionException &e) {
      std::cout<<"Terminated due to AssertionException: "<<std::endl<<e.what()<<std::endl;
      return 1;
    }
  }
コード例 #4
0
ファイル: main.c プロジェクト: FlavioFalcao/tinq-core
int do_switches (int argc, const char **argv)
{
	int		i, help;
	const char	*cp;

	progname = argv [0];
	help = 0;
	for (i = 1; i < argc; i++) {
		cp = argv [i];
		if (*cp++ != '-')
			break;

		while (*cp) {
			switch (*cp++) {
				case 'l':
					list_tests ();
					exit (0);
					break;
				case 'i':
					introspect = 1;
					break;
				case 't':
					dump_type = 1;
					break;
				case 'd':
					dump_data = 1;
					break;
				case 'y':
					dump_typecode = 1;
					break;
				case 'v':
					verbose = 1;
					if (*cp == 'v') {
						introspect = 1;
						dump_type = 1;
						dump_data = 1;
						parse_data = 1;
						dump_typecode = 1;
						cp++;
					}
					break;
				case 'h':
					help = 1;
				default:
					if (!help)
						fprintf (stderr, "Unknown option!\r\n");
					usage ();
				break;
			}
		}
	}
	return (i);
}
コード例 #5
0
ファイル: Curses.c プロジェクト: RajasekharBhumi/L4Re
/** Run a selected suite within the curses interface.
 * Displays actions and responds based on user imput.
 * @param pSuite The suite to use for testing (non-NULL).
 */
static STATUS curses_suite_level_run(CU_pSuite pSuite)
{
  char szTestName[STRING_LENGTH];
  CU_pTest pTest = NULL;

  f_szOptions = SUITE_OPTIONS;
  refresh_options_window();

  while (true) {
    int option = toupper(getch());

    switch (option) {
      case 'R':
        curses_run_suite_tests(pSuite);
        break;

      case 'S':
        read_input_string("Enter Test Name : ", szTestName, STRING_LENGTH);
        if (NULL != (pTest = CU_get_test_by_name(szTestName, pSuite))) {
          curses_run_single_test(pSuite, pTest);
        }
        refresh_details_window();
        break;

      case 'L':
        list_tests(pSuite);
        break;

      case 'F':
        show_failures();
        break;

      case 'U':
        return CONTINUE;

      case 'Q':
        return STOP;

      case KEY_UP:
      case KEY_DOWN:
      case KEY_RIGHT:
      case KEY_LEFT:
        scroll_window(option, &details_pad, refresh_details_window);
        break;

      default:
        break;
    }
  }

  return CONTINUE;
}
コード例 #6
0
ファイル: performance_tests.c プロジェクト: sproates/ocarina
int main(void) {
  printf("\n\n----------------------------------\n\n");
  printf("Performance tests.\n");
  printf("\n\n----------------------------------\n\n");

  list_tests();

  printf("\n\n----------------------------------\n\n");
  printf("Number of performance tests: %d\n", number_of_tests);
  printf("Completed in %d sec %d millis.\n", (int)(cpu_time / 1000), (int)(cpu_time % 1000));
  printf("\n\n----------------------------------\n\n");
  return 0;
}
コード例 #7
0
ファイル: structs.c プロジェクト: antrik/libggi
/* Check arguments.
 */
static int parse_args(int argc, const char *argv[])
{
	int x,testnum;

	for (x=1;x<argc;x++) {
		if (*argv[x]=='-') {
			switch(argv[x][1]) {

				case '?': list_tests();return 1;
				case '-':
					for (testnum=0;tests[testnum].name;
					     testnum++) {
						if (strcmp(tests[testnum].name,
							   argv[x]+2)==0 ||
						    strcmp("all", argv[x]+2)
						    ==0) {
							tests[testnum].active=1;
						}
					}
					break;
				default:
					fprintf(stderr,
						"%s: Unknown switch '%s' !\n\n",
						argv[0],argv[x]);
					usage(argv[0]);
					return 1;
			}
		}
		else {
			fprintf(stderr,"%s: Can't parse '%s'.\n\n",argv[0],argv[x]);
			usage(argv[0]);
			return 1;
		}
	}	

	return 0;
}
コード例 #8
0
ファイル: parsecl.c プロジェクト: azet/dieharder
void parsecl(int argc, char **argv)
{

 /*
  * Thus far, dieharder has used getopt() to parse the CL.  However, this
  * isn't as flexible as one might like.  To manage CLI-driven control
  * flags and a few other things, we may need to parse out options the
  * hard way in a future release.  The following variables are pretty much
  * all to support getopt and would change if we change parsing tools or
  * strategies.
  */

 int i,c,errflg=0;
 int itmp;
 int tflag_tmp = 0,dtest_tmp,gen_tmp=17;
 extern char *optarg;
 extern int optind, opterr, optopt;
 char *endptr;

 /*
  * If dieharder is executed by itself on a command line, print out help
  * and then exit.  dieharder cannot be run without options, in other
  * words.
  */
 if(argc == 1){
    Usage();
    exit(1); /* count this as an error */
 }

 while ((c = getopt(argc,argv,"aBc:D:d:Ff:g:hi:k:lL:m:n:oO:p:P:S:s:t:Vv:W:X:x:Y:y:Z:z:")) != EOF){
   switch (c){
     case 'a':
       all = YES;
       break;
     case 'B':
       output_format = 0;
	   fprintf(stderr, "Warning: \"-B\" option is deprecated.  Use \"-O 0\" instead.\n");
       break;
     case 'c':
       /* printf("Setting separator to %c\n",optarg[0]); */
       table_separator = (char) optarg[0];
       break;
     case 'D':
       /*
        * We only override the default table display flags if there is
        * actually an argument to -D.  I hope.
        */
       tflag_tmp =  strtol(optarg,&endptr,10);
       if(*endptr != 0){
         /*
	  * This trick will be useful for parsing both random
	  * number generator names and test names.  Try to convert
	  * the string to a number, but if the conversion fails
	  * then try to lookup a string instead and convert to
	  * the index/number needed.
	  */
	 for(i=0;i<TCNT;i++){
	   if(strncmp(optarg,table_fields[i],TLENGTH) == 0){
             /* printf("Setting table option %s.\n",optarg); */
	     /*
	      * If default is set explicitly, just add tflag_default
	      * to presumed zero tflag.
	      */
	     if(i == 0){
	       tflag = tflag_default;
	     } else {
               tflag_tmp = (int) pow(2,i-1);
	     }
	     break;
	   }
	 }
	 if(i == TCNT) {
	   fprintf(stderr,"Invalid -T %s option.\n",optarg);
	   exit(1);
	 }
       }
       if(tflag_tmp == 0){
         /*
	  * If default is set explicitly, just set tflag to the value of
	  * tflag_default.  This means one can ADD a feature (e.g. prefix)
	  * easily but don't add any twice!  Note that an undocumented
	  * feature is that one can subtract flag values from the default
	  * as well, but numerically only.
	  */
         tflag = tflag_default;
       } else {
         /*
	  * We accumulate tflag from zero.
	  */
         tflag += tflag_tmp;
       }
       break;
     case 'd':
       /*
        * We need to set dtest_num, either from a number or by searching
        * the dh_test_types[] set of tests for a string/name match.  We
	* also have to be sure to leave dtest_num negative if we set
	* dtest_name, since that is the signal to search for the number
	* later.
        */
       dtest_tmp =  strtol(optarg,&endptr,10);
       /* printf("optarg = %s, dtest_tmp = %d endptr = %s\n",optarg,dtest_tmp,endptr); */
       if(strncmp(optarg,endptr,1) == 0){
         strncpy(dtest_name,optarg,128);
       } else {
         dtest_num = dtest_tmp;
       }
       break;
     case 'F':
       show_flags = 1;
       break;
     case 'f':
       strncpy(filename,optarg,128);
       fromfile = 1;
       break;
     /*
      * The dieharder CLI supports a "super" XOR generator.  Multiple
      * instances (up to GVECMAX = 100) of generators and associated seeds
      * on the command line cause this generator to automagically be used.
      * It simply XOR's together the sequential output of all the
      * generators, (uint) word by word, and returns that as a standard
      * uint/udev gsl generator.  The parsing code below thus simply moves
      * the CLI entries into the appropriate global vectors, to be handled
      * by the choose_rng function later.
      */
     case 'g':
       gen_tmp =  strtol(optarg,&endptr,10);
       /* printf("optarg = %s, dtest_tmp = %d endptr = %s\n",optarg,dtest_tmp,endptr); */
       if(strncmp(optarg,endptr,1) == 0){
         strncpy(gnames[gvcount],optarg,128);
       } else {
         gnumbs[gvcount] = gen_tmp;
       }
       gvcount++;
       break;
     case 'h':
       help_flag = YES;
       break;
     case 'i':
       iterations = strtol(optarg,(char **) NULL,10);
       break;
     case 'k':
       ks_test = strtol(optarg,(char **) NULL,10);
       break;
     case 'l':
       list = YES;
       break;
     case 'L':
       overlap = strtol(optarg,(char **) NULL,10);
       break;
     case 'm':
       multiply_p = strtod(optarg,(char **) NULL);
       /*
        * Safety checking on multiply_p is done in std_test, where
        * more information (the number of p-samples) is available.
        */
       break;
     case 'n':
       ntuple = strtol(optarg,(char **) NULL,10);
       break;
     case 'o':
       output_file = 1;
       break;
     case 'O':
       output_format = strtol(optarg,(char **) NULL,10);
       if(output_format > 2){
         fprintf(stderr,"-O %u format not recognized.\n",output_format);
	 fprintf(stderr," Choices: 0 (binary), 1 (uint), 2 (decimal)\n");
       }
       break;
     case 'P':
       Xoff = strtol(optarg,(char **) NULL,10);
       break;
     case 'p':
       psamples = strtol(optarg,(char **) NULL,10);
       break;
     case 'S':
       Seed = strtol(optarg,(char **) NULL,10);
       gseeds[gscount] = gen_tmp;
       gscount++;
       break;
     case 's':
       strategy = strtol(optarg,(char **) NULL,10);
       break;
     case 't':
       itmp = strtol(optarg,(char **) NULL,10);
       /*
        * For a variety of reasons, we can't yet manage a full uint here,
        * nor can we deal with a negative number.  HOWEVER, we DO have
	* a really big ull tsamples, and we really SHOULD do our checking
	* for excessive size elsewhere.
        */
       if(itmp>=0){
         tsamples = itmp;
       } else {
         fprintf(stderr,"Warning!  tsamples cannot be negative = %d\n",itmp);
	 fprintf(stderr,"          using default tsamples value(s).\n");
	 fflush(stderr);
       }
       break;
     case 'V':
       dh_version();
       exit(0);
       break;
     case 'v':
       verbose = strtol(optarg,(char **) NULL,10);
       printf("# Verbose is now %d\n",verbose);
       break;
     case 'W':
       Xweak = strtod(optarg,(char **) NULL);
       break;
     case 'X':
       Xfail = strtod(optarg,(char **) NULL);
       break;
     case 'x':
       x_user = strtod(optarg,(char **) NULL);
       break;
     case 'Y':
       Xtrategy = strtol(optarg,(char **) NULL,10);
       break;
     case 'y':
       y_user = strtod(optarg,(char **) NULL);
       break;
     case 'z':
       z_user = strtod(optarg,(char **) NULL);
       break;
     case '?':
       errflg++;
   }
 }

 /*
  * By the time we get here, all the command line options should have
  * been processed, and we are ready to act on them.  There are a small
  * set of options that we act on right away below, mostly associated with
  * the autodocumenting features of the dieharder CLI (only).
  * Interfaces such as Rdieharder should just ifdef them out, or better
  * yet, not use this routine at all since it should invariably be faster
  * and easier to just set the options directly instead of building a
  * fake command line to hand off to parsecl().
  */

 /*
  * Some option was set incorrectly.
  */
 if(errflg){
   Usage();
   exit(0);
 }

 /*
  * If there are no more arguments it is a legal command.  We execute
  * some of the simpler, autodocumenting ones right here and then
  * immediately exit.
  */
 if(argc-optind == 0){

   /*
    * If a list of tests was requested, print it and exit.
    */
   if(list == YES) {
     list_tests();
     Exit(0);
   }

   /*
    * If a list of all the generators was requested, we give it, but
    * list_rngs() won't work until after the types[] list is built.
    * I could probably do this several ways, but this one is quite
    * simple and works fine.
    */
   if(generator == -1){
     list_rngs();
     Exit(0);
   }

   if(show_flags == 1){
     dh_header();
     fprintf(stdout," Dieharder output control flags.  Set with -D flagname or -D flag\n");
     fprintf(stdout," Multiple flags may be given:\t\tdieharder -a -D test_name -D pvalues.\n");
     fprintf(stdout," Flags names and numbers may be mixed:\tdieharder -a -D 8 -D pvalues.\n");
     fprintf(stdout," Flag\t    Flag Name\n");
     fprintf(stdout,"=======================\n");
     fprintf(stdout,"%5d\t%15s\n",0,table_fields[0]);
     for(i=0;i<TCNT;i++){
       fprintf(stdout,"%5d\t%15s\n",(int)pow(2,i),table_fields[i+1]);
     }
     Exit(0);
   }

   /*
    * If help was requested, call the help routine.  This routine does
    * different things depending on the other flags and variables, so
    * we defer calling it until they are all set.  help() will exit.
    */
   if(help_flag) help();

   /*
    * This one is tricky, but:  If tflag_tmp == 0, it means that either we
    * did not get any -D flags OR that we ONLY got -D 0.  Either way, we
    * have to set tflag to the default if we get here.  The one "odd"
    * behavior this will produce is that -D 8 -D 0 will effectively be -D
    * 0, where -D 0 -D -8 will actually turn OFF feature 8 from the
    * default list.  I don't plan to document this further anywhere but
    * here, but I may use it...;-)
    */
   if(tflag_tmp == 0){
     tflag = tflag_default;
   }

   /*
    * If we get here, it is time to move on and execute dieharder
    */
   return;

 }

 /*
  * Leftover commands on the command line are errors and should trigger
  * the standard Usage message and exit.
  */

 Usage();
 

}
コード例 #9
0
ファイル: main.c プロジェクト: DINKIN/bladeRF
int get_params(int argc, char *argv[], struct app_params *p)
{
    int c, idx;
    bool ok;
    bladerf_log_level level;

    memset(p, 0, sizeof(p[0]));
    p->randval_seed = 1;

    while((c = getopt_long(argc, argv, OPTARG, long_options, &idx)) != -1) {
        switch (c) {
            case 'd':
                if (p->device_str) {
                    fprintf(stderr, "Device already specified!\n");
                    return -1;
                } else {
                    p->device_str = strdup(optarg);
                    if (p->device_str == NULL) {
                        perror("strdup");
                        return -1;
                    }
                }
                break;

            case 't':
                if (p->test_name) {
                    fprintf(stderr, "Test already specified!\n");
                    return -1;
                } else {
                    p->test_name = strdup(optarg);
                    if (p->test_name == NULL) {
                        perror("strdup");
                        return -1;
                    }
                }
                break;

            case 's':
                p->randval_seed = str2uint64(optarg, 1, UINT64_MAX, &ok);
                if (!ok) {
                    fprintf(stderr, "Invalid seed value: %s\n", optarg);
                    return -1;
                }
                break;

            case 'h':
                usage(argv[0]);
                return 1;

            case 1:
                p->use_xb200 = true;
                break;

            case 'L':
                list_tests();
                return 1;

            case 'v':
                level = str2loglevel(optarg, &ok);
                if (ok) {
                    bladerf_log_set_verbosity(level);
                } else {
                    fprintf(stderr, "Invalid log level: %s\n", optarg);
                    return -1;
                }
                break;

            default:
                return -1;
        }
    }

    return 0;
}
コード例 #10
0
ファイル: weston-test-runner.c プロジェクト: whot/weston
int main(int argc, char *argv[])
{
	const struct weston_test *t;
	pid_t pid;
	int total, pass;
	siginfo_t info;

	if (argc == 2) {
		const char *testname = argv[1];
		if (strcmp(testname, "--help") == 0 ||
		    strcmp(testname, "-h") == 0) {
			fprintf(stderr, "Usage: %s [test-name]\n", program_invocation_short_name);
			list_tests();
			exit(EXIT_SUCCESS);
		}

		t = find_test(argv[1]);
		if (t == NULL) {
			fprintf(stderr, "unknown test: \"%s\"\n", argv[1]);
			list_tests();
			exit(EXIT_FAILURE);
		}

		run_test(t);
	}

	pass = 0;
	for (t = &__start_test_section; t < &__stop_test_section; t++) {
		int success = 0;
		int hardfail = 0;

		pid = fork();
		assert(pid >= 0);

		if (pid == 0)
			run_test(t); /* never returns */

		if (waitid(P_ALL, 0, &info, WEXITED)) {
			fprintf(stderr, "waitid failed: %m\n");
			abort();
		}

		fprintf(stderr, "test \"%s\":\t", t->name);
		switch (info.si_code) {
		case CLD_EXITED:
			fprintf(stderr, "exit status %d", info.si_status);
			if (info.si_status == EXIT_SUCCESS)
				success = 1;
			break;
		case CLD_KILLED:
		case CLD_DUMPED:
			fprintf(stderr, "signal %d", info.si_status);
			if (info.si_status != SIGABRT)
				hardfail = 1;
			break;
		}

		if (t->must_fail)
			success = !success;

		if (success && !hardfail) {
			pass++;
			fprintf(stderr, ", pass.\n");
		} else
			fprintf(stderr, ", fail.\n");
	}

	total = &__stop_test_section - &__start_test_section;
	fprintf(stderr, "%d tests, %d pass, %d fail\n",
		total, pass, total - pass);

	return pass == total ? EXIT_SUCCESS : EXIT_FAILURE;
}