Exemplo n.º 1
0
int main(int argc, char **argv) {

    if( argc < 2 ) {
        tests_run(-1);
        return 0;
    }

    if( !strncmp("list", argv[1], strlen("list")) ) {
        int i = 0;
        int k = sizeof(tests)/sizeof(tests[0]);
        for(i = 0; i < k && tests[i].test_fun; i++) {
            fprintf(stderr, "%3d %s\n", i, tests[i].name );
        }
        return 0;
    }

    char *e = argv[1];
    long n = strtol(argv[1], &e, 10);
    if( e > argv[1] ) {
        tests_run(n);
        return 0;
    }

    return -1;
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
  int res;

  mtx_init(&gMutex, mtx_plain);
  cnd_init(&gCond);

  res = tests_run(unit_tests, argc, argv);

  mtx_destroy(&gMutex);
  cnd_destroy(&gCond);

  return res;
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
	cmd_args_t *args = NULL;
	int rc = 0;

	/* General init */
	if ((rc = init()))
		return rc;

	/* Device specific init */
	if ((rc = dev_init()))
		goto out;

	/* Argument init and parsing */
	if ((args = args_init(argc, argv)) == NULL) {
		rc = -1;
		goto out;
	}

	/* Generic kernel version string */
	if (args->args_verbose)
		fprintf(stdout, "%s", splat_version);

	/* Print the available test list and exit */
	if (args->args_do_list) {
		subsystem_list(subsystems, 0);
		goto out;
	}

	/* Add all available test to the list of tests to run */
	if (args->args_do_all) {
		if ((rc = test_add_all(args)))
			goto out;
	}

	/* Run all the requested tests */
	if ((rc = tests_run(args)))
		goto out;

out:
	if (args != NULL)
		args_fini(args);

	dev_fini();
	fini();
	return rc;
}
Exemplo n.º 4
0
    int
main ( int argc, char **argv )
{
    int   fatal = 0;
    FILE *stdterm = NULL; /* default writing to stdout */

    name0 = strrchr( argv[0], '/' );
    if ( name0 )
       name0++;
    else
       name0 = argv[0];

  {
    int   c;

    while( ( c = getopt( argc, argv, "cCeEnrtw::xzZ::" ) ) != -1 )
    {
      switch( c )
      {

	case 'c':
	  opt_c++;
	  break;
	case 'C':
	  opt_c = 0;
	  break;

	case 'e':
	  opt_e++;
	  break;

	case 'E':
	  opt_e = 0;
	  break;

	case 'n':
	  opt_n++;
	  break;

	case 'r':
	  opt_r++;
	  break;

	case 't':
	  opt_t = optarg;
	  break;

        case 'w':
	 {
	   int  width;
	   width = atoi( optarg );
	   if ( width >= 21 )	/* assure reasonable (fear <= 9; <= 16 ugly) */
	       opt_w = width;	
	   break;
	 }

 	case 'x':		/* discard this for historical reasons */
	  break;

	case 'z':
	  opt_z++;
	  break;

	/* undocumented, unsupported, feature, subject to change w/o notice. */
	case 'Z':
	  if ( tests_run( optarg ) < 0 )
	      fatal++;
	  break;

	default:
	  fatal++;
	  break;

      }
    }

    if ( opt_t && *opt_t )
    {
	stdterm = fopen( opt_t, "r+" );
	if ( ! stdterm )
	    die( "CAN NOT OPEN OUTPUT TERMINAL AT %s: %s\n",
	    		opt_t, strerror(errno) );
    }
    else
    {
	stdterm = stdout;
    }

  }
    if ( fatal ) exit( EXIT_FAILURE );

  {
     int   a;

     for ( a = optind; a < argc; a++ )
     {
	arg( stdterm, opt_c, argv[a] );
     }
  }

    if ( closure ) fputc( closure[0], stdterm );	/* close dangling code */

    if ( ! opt_n )
	putc( '\n', stdterm );
    else
	fflush( stdterm );		/* else assure stdterm flushed */

    if ( opt_r )
    {   /* reading response and relaying to stdout */
	struct timeval timeout;
	int     fd = ( stdout == stdterm ) ? fileno(stdin) : fileno(stdterm);

	while ( 1 )
        {   /* character is avaiable */
	    fd_set  readfds;
	    fd_set  exceptfds;
	    int     n;

	    FD_ZERO( &readfds );
	    FD_ZERO( &exceptfds );
	    FD_SET( fd, &readfds );		/* assure only bit we want is set */
	    timeout.tv_sec = 1; 		/* set timeout */
	    timeout.tv_usec = 0; 
	    n = select( 1 + fd, &readfds, NULL, &exceptfds, &timeout );
	    if ( n < 1 )
	        break;			/* no data: exit */

	    if ( FD_ISSET( fd, &readfds ) )	
	    {   /* at least one byte has been promised to us */
		char   buf[2];
		ssize_t bytes = read( fd,  buf, 1 );	/* direct read */
		if ( bytes > 0 )
		    putc( buf[0], stdout );
	    }
	    if ( FD_ISSET( fd, &exceptfds ) )	
		break;
	}
	fflush( stdout );		/* else assure stdout flushed */
    }

    if ( stdterm != stdout )
        fclose( stdterm );

    return( EXIT_SUCCESS );
}