int main(int argc, char *argv[])
{
if(argc != 1)
    usage();
doTests();
return 0;
}
Esempio n. 2
0
int main(int /*argc*/,char* /*argv[]*/)
{


  doTests();

  return 0;
}
Esempio n. 3
0
int main()
{
    int patient;
    cin >> patient;
    while (patient > 0){
    cout << "patient " << patient << '\n';
    doTests();
    cin >> patient;
    }
    return 0;    
}
int main(int argc, char **argv) {
    atexit(exitHelper);

    myName = argv[0];
    KApplication app(argc, argv, "testhealpix", false, false);

    doTests();

    exitHelper(); // before app dies
    if (rc == KstTestSuccess) {
        printf("All tests passed!\n");
    }
    return -rc;
}
int main(int argc, char **argv) {
  atexit(exitHelper);

  KApplication app(argc, argv, "testvector", false, false);

  doTests();
  // Don't put tests in main because we need to ensure that no KstObjects
  // remain past the exit handler

  exitHelper(); // need to run it here before kapp goes away in some cases.
  if (rc == KstTestSuccess) {
    printf("All tests passed!\n");
  }
  return -rc;
}
Esempio n. 6
0
int main(int argc, const char* argv[]) {

  std::string sortname = "quick";

  if (argc > 1)
    sortname = argv[1];

  prepareTestData();

  doTests(sortname);
  
  cleanUp();

  return 0;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
	double			elapsed;
	char			*programName, *argp, *logSpec;
	int				c, errflg, start;
#if BLD_FEATURE_LOG
	MprLogToFile	*logger;
#endif
#if BLD_FEATURE_MULTITHREAD
	MprThread		*threadp;
#endif

	programName = mprGetBaseName(argv[0]);
	method = "GET";
	fileList = cmpDir = writeDir = 0;
	verbose = continueOnErrors = outputHeader = errflg = 0;
	poolThreads = 4;			// Need at least one to run efficiently
	httpVersion = 1;			// HTTP/1.1
	success = 1;
	trace = 0;
	host = "localhost";
	logSpec = "stdout:1";
	postData = 0;
	postLen = 0;
	retries = MPR_HTTP_CLIENT_RETRIES;
	iterations = HTTP_DEFAULT_ITERATIONS;
	loadThreads = HTTP_DEFAULT_LOAD_THREADS;
	timeout = MPR_HTTP_CLIENT_TIMEOUT;

#if BLD_FEATURE_MULTITHREAD
	mutex = new MprMutex();
#endif

	//
	//	FUTURE: switch to GNU style --args with a better usage message
	//
	MprCmdLine	cmdLine(argc, argv, "bC:cDd:f:Hh:i:l:M:mqo:r:st:T:vV:w:");
	while ((c = cmdLine.next(&argp)) != EOF) {
		switch(c) {
		case 'b':
			benchmark++;
			break;

		case 'c':
			continueOnErrors++;
			break;

		case 'C':
			cmpDir = argp;
			break;

		case 'd':
			postData = argp;
			postLen = strlen(postData);
			break;

		case 'D':
			mprSetDebugMode(1);
			break;

		case 'f':
			fileList = argp;
			break;

		case 'h':
			host = argp;
			break;

		case 'H':
			outputHeader++;
			break;

		case 'i':
			iterations = atoi(argp);
			break;

		case 'l':
			logSpec = argp;
			break;

		case 'm':
			mprRequestMemStats(1);
			break;

		case 'M':
			method = argp;
			break;

		case 'o':
			timeout = atoi(argp);
			break;

		case 'q':
			quietMode++;
			break;

		case 'r':
			retries = atoi(argp);
			break;

		case 's':
			singleStep++;
			break;

		case 't':
			loadThreads = atoi(argp);
			break;

		case 'T':
			poolThreads = atoi(argp);
			break;

		case 'v':
			verbose++;
			trace++;
			break;

		case 'V':
			httpVersion = atoi(argp);
			break;

		case 'w':
			writeDir = argp;
			break;

		default:
			errflg++;
			break;
		}
	}
	if (writeDir && (loadThreads > 1)) {
		errflg++;
	}

	if (errflg) {
		mprFprintf(MPR_STDERR, 
			"usage: %s [-bcHMmqsTv] [-C cmpDir] [-d postData] [-f fileList]\n"
			"	[-i iterations] [-l logSpec] [-M method] [-o timeout]\n"
			"	[-h host] [-r retries] [-t threads] [-T poolThreads]\n"
			"	[-V httpVersion] [-w writeDir] [urls...]\n", programName);
		exit(2);
	}
	saveArgc = argc - cmdLine.firstArg();
	saveArgv = &argv[cmdLine.firstArg()];

	mpr = new Mpr(programName);

#if BLD_FEATURE_LOG
	tMod = new MprLogModule("httpClient");
	logger = new MprLogToFile();
	mpr->addListener(logger);
	if (mpr->setLogSpec(logSpec) < 0) {
		mprFprintf(MPR_STDERR, "Can't open log file %s\n", logSpec);
		exit(2);
	}
#endif

	//
	//	Alternatively, set the configuration manually
	//
	mpr->setAppTitle("Embedthis HTTP Client");
#if BLD_FEATURE_MULTITHREAD
	mpr->setMaxPoolThreads(poolThreads);
#endif

	//
	//	Start the Timer, Socket and Pool services
	//
	if (mpr->start(MPR_SERVICE_THREAD) < 0) {
		mprError(MPR_L, MPR_USER, "Can't start MPR for %s", mpr->getAppTitle());
		delete mpr;
		exit(2);
	}

	//
	//	Create extra test threads to run the tests as required. We use
	//	the main thread also (so start with j==1)
	//
	start = mprGetTime(0);
#if BLD_FEATURE_MULTITHREAD
	activeLoadThreads = loadThreads;
	for (int j = 1; j < loadThreads; j++) {
		char name[64];
		mprSprintf(name, sizeof(name), "t.%d", j - 1);
		threadp = new MprThread(doTests, MPR_NORMAL_PRIORITY, (void*) j, name); 
		threadp->start();
	}
#endif

	doTests(0, 0);

	//
	//	Wait for all the threads to complete (simple but effective). Keep 
	//	servicing events as we wind down.
	//
	while (activeLoadThreads > 1) {
		mprSleep(100);
	}

	if (benchmark && success) {
		elapsed = (mprGetTime(0) - start);
		if (fetchCount == 0) {
			elapsed = 0;
			fetchCount = 1;
		}
		mprPrintf("\tThreads %d, Pool Threads %d   \t%13.2f\t%12.2f\t%6d\n", 
			loadThreads, poolThreads, elapsed * 1000.0 / fetchCount, 
			elapsed / 1000.0, fetchCount);

		mprPrintf("\nTime elapsed:        %13.4f sec\n", elapsed / 1000.0);
		mprPrintf("Time per request:    %13.4f sec\n", elapsed / 1000.0 
			/ fetchCount);
		mprPrintf("Requests per second: %13.4f\n", fetchCount * 1.0 / 
			(elapsed / 1000.0));
	}
	if (! quietMode) {
		mprPrintf("\n");
	}

	mpr->stop(0);

#if BLD_FEATURE_MULTITHREAD
	delete mutex;
#endif
#if BLD_FEATURE_LOG
	delete tMod;
#endif

	delete mpr;
#if BLD_FEATURE_LOG
	delete logger;
#endif
	mprMemClose();
	return (success) ? 0 : 255;
}
Esempio n. 8
0
/* Run the test suite. This must be called with exactly one parameter, the
 * name of the test suite. For details, see file header comment at the top
 * of this file.
 * rgerhards, 2009-04-03
 */
int main(int argc, char *argv[])
{
	int fd;
	int opt;
	int ret = 0;
	FILE *fp;
	char buf[4096];
	char testcases[4096];

	while((opt = getopt(argc, argv, "dc:i:p:t:v")) != EOF) {
		switch((char)opt) {
                case 'c':
			pszCustomConf = optarg;
			break;
                case 'd': 
			useDebugEnv = 1;
			break;
                case 'i':
			if(!strcmp(optarg, "udp"))
				inputMode = inputUDP;
			else if(!strcmp(optarg, "tcp"))
				inputMode = inputTCP;
			else {
				printf("error: unsupported input mode '%s'\n", optarg);
				exit(1);
			}
			break;
                case 'p':
			iPort = atoi(optarg);
			break;
                case 't':
			testSuite = optarg;
			break;
                case 'v':
			verbose = 1;
			break;
		default:printf("Invalid call of nettester, invalid option '%c'.\n", opt);
			printf("Usage: nettester -d -ttestsuite-name -iudp|tcp [-pport] [-ccustomConfFile] \n");
			exit(1);
		}
	}
	
	if(testSuite == NULL) {
		printf("error: no testsuite given, need to specify -t testsuite!\n");
		exit(1);
	}

	atexit(doAtExit);

	if((srcdir = getenv("srcdir")) == NULL)
		srcdir = ".";

	if(verbose) printf("Start of nettester run ($srcdir=%s, testsuite=%s, input=%s/%d)\n",
		srcdir, testSuite, inputMode2Str(inputMode), iPort);

	/* create input config file */
	if((fp = fopen(NETTEST_INPUT_CONF_FILE, "w")) == NULL) {
		perror(NETTEST_INPUT_CONF_FILE);
		printf("error opening input configuration file\n");
		exit(1);
	}
	if(inputMode == inputUDP) {
		fputs("$ModLoad ../plugins/imudp/.libs/imudp\n", fp);
		fprintf(fp, "$UDPServerRun %d\n", iPort);
	} else {
		fputs("$ModLoad ../plugins/imtcp/.libs/imtcp\n", fp);
		fprintf(fp, "$InputTCPServerRun %d\n", iPort);
	}
	fclose(fp);

	/* start to be tested rsyslogd */
	openPipe(testSuite, &rsyslogdPid, &fd);
	readLine(fd, buf);

	/* generate filename */
	sprintf(testcases, "%s/testsuites/*.%s", srcdir, testSuite);
	if(doTests(fd, testcases) != 0)
		ret = 1;

	if(verbose) printf("End of nettester run (%d).\n", ret);
	exit(ret);
}
void testLookupField (unsigned size)
{
   typedef unsigned char u8;

   int maxDim   = logInt (256u, size);
   int maxDim32 = logInt (std::numeric_limits<unsigned>::max(), size);

   unsigned p;
   int e;

   if (Prime::isPrimePower (size, p, e))
   {
      // general case

      {
         typedef LookupField<u8> F;
         LookupGaloisField<u8> f (size);
         doTests (f, "LookupField<>");

         typedef PolynomialRing<F> PF;
         PF pf (f);
         doTests (pf, "PolynomialRing<LookupField<> >");

         doTests (PolynomialRing<PF> (pf, 'y'),
                  "PolynomialRing<PolynomialRing<LookupField<> > >");

         doTests (QuotientField<PF> (pf),
                 "QuotientField<PolynomialRing<LookupField<> > >");

         doTests (OneDimVectorSpace<F> (f),
                  "OneDimVectorSpace<LookupField<> >");

         for (int j = 1; j <= maxDim; ++j)
         {
            doTests (LookupVectorSpace<u8,u8>(f, j), "LookupVectorSpace<>");
         }
      }
     
      // optimized version for primes

      if (e == 1)
      {
         typedef LookupFieldPrime<u8> F;
         LookupGaloisFieldPrime<u8> f (size);
         doTests (f, "LookupFieldPrime<>");

         doTests (PolynomialRing<F> (f),
                  "PolynomialRing<LookupFieldPrime<> >");
         doTests (OneDimVectorSpace<F> (f),
                  "OneDimVectorSpace<LookupFieldPrime<> >");
      }
     
      // optimized version for powers of 2

      if (p == 2)
      {
         typedef LookupFieldPow2<u8> F;
         LookupGaloisFieldPow2<u8> f (size);
         doTests (f, "LookupFieldPow2<>");

         doTests (PolynomialRing<F> (f),
                  "PolynomialRing<LookupFieldPow2<> >");
         doTests (OneDimVectorSpace<F> (f),
                  "OneDimVectorSpace<LookupFieldPow2<> >");

         for (int j = 1; j <= maxDim; ++j)
         {
            doTests (LookupVectorSpacePow2<u8,u8>(f,j),
                     "LookupVectorSpacePow2<>");
         }

         for (int j = 1; j <= maxDim32; ++j)
         {
            doTests (VectorSpacePow2<u32>(f,j), "VectorSpacePow2<>");
         }
      }
   }
}
Esempio n. 10
0
int main(int argc, const char * argv[]) {
    // insert code here...
    doTests();
    return 0;
}