Ejemplo n.º 1
0
int main (int argc, char *argv[])
{
	char *fn;
	unsigned int verfd = 0;

	fn = getenv("TEST_TESTNET3_VERF");
	if (fn) {
		verfd++;
		runtest(true, fn);
	}

	fn = getenv("TEST_MAINNET_VERF");
	if (fn) {
		verfd++;
		runtest(false, fn);
	}

	if (!verfd) {
		fprintf(stderr,
	"chain-verf: Skipping lengthy, extended chain verification test.\n"
	"chain-verf: Set TEST_TESTNET3_VERF and/or TEST_MAINNET_VERF to a\n"
	"chain-verf: valid pynode blocks.dat file, to enable.\n"
	"chain-verf: (a linear sequence of P2P \"block\" messages)\n"
			);
		return 77;
	}
	
	return 0;
}
Ejemplo n.º 2
0
void
cowMng2(size_t length)
{

    int fd = open(fileName, O_RDWR);
    char* shared = (char*)mmap(NULL, length, PROT_READ|PROT_WRITE,
			       MAP_SHARED, fd, 0);

    char* priv = (char*)mmap(NULL, length, PROT_READ|PROT_WRITE,
			     MAP_PRIVATE, fd, 0);

    if (~0UL == (unsigned long)shared) {
	printf("Error: %d %s\n", errno, strerror(errno));
    }

    if (~0UL == (unsigned long)priv) {
	printf("Error: %d %s\n", errno, strerror(errno));
    }

    double result1 = runtest(priv, length, 1);
    double result2 = runtest(shared, length, 1);
    munmap(priv, length);
    munmap(shared, length);
    printf("0x%4lx shared: %6.2lfus private: %6.2lfus\n",
	   length/PAGE_SIZE, result2, result1);
    close(fd);
}
Ejemplo n.º 3
0
void
hpteEntry(size_t length)
{
    char* start = (char*)mmap(NULL, length, PROT_READ|PROT_WRITE,
			      MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

    if (~0UL == (unsigned long)start) {
	printf("Error: %d %s\n", errno, strerror(errno));
    }
    double result1 = runtest(start, length, 1);

    int ret = mflush((unsigned long)start, ((unsigned long)start) + length);
    if (ret < 0) {
	if (errno==ENOSYS)
	    return;
	printf("mflush error: %d %s\n", errno, strerror(errno));
    }

    double result2 = runtest(start, length, 1);


    munmap(start, length);
    printf("0x%4lx hpteEntry write: %.2lfus %.2lfus\n",
	   length/PAGE_SIZE, result1, result2);
}
Ejemplo n.º 4
0
void
forkFault(size_t length)
{
    char* start = (char*)mmap(NULL, length, PROT_READ|PROT_WRITE,
			      MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

    if (~0UL == (unsigned long)start) {
	printf("Error: %d %s\n", errno, strerror(errno));
    }
    double result1 = runtest(start, length, 1);
    double result2;
    int pipes[2];
    pipe(pipes);
    pid_t pid = fork();
    if (pid==0) {
	result2 = runtest(start, length, 1);
	write(pipes[1], &result2, sizeof(result2));
	exit(0);
    } else {
	read(pipes[0], &result2, sizeof(result2));
	wait(NULL);
    }

    double result3 = runtest(start, length, 1);

    munmap(start, length);
    printf("0x%4lx fork: pre: %.2lfus child: %.2lfus parent: %.2lfus\n",
	   length/PAGE_SIZE, result1, result2, result3);
}
Ejemplo n.º 5
0
void test_numbers()
{
  runtest("12345T",0x23450001);
  runtest("F.1234T",0xF1234);
  runtest("123456789ABCDT",0xABCD6789);
  runtest("1234.56789AT",0x9A345678);
  runtest("1.15.25+T",0x13A00);
}
Ejemplo n.º 6
0
int main (int argc, char *argv[])
{
	runtest("data/blk0.json", "data/blk0.ser");
	runtest("data/blk120383.json", "data/blk120383.ser");

	bp_key_static_shutdown();
	return 0;
}
Ejemplo n.º 7
0
int main (int argc, char *argv[])
{
	runtest(true, "tx_valid.json");
	runtest(false, "tx_invalid.json");

	bp_key_static_shutdown();
	return 0;
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{
   int i, srclen, dstlen, ifreq;
   double factor;

   printf("\n*** Vary source block size*** \n\n");
   srclen = 10000;
   ifreq = 100;
   for(i=0; i<20; i++) {
      factor = ((rand() % 16) + 1) / 4.0;
      dstlen = (int)(srclen * factor + 10);
      runtest(srclen, (double)ifreq, factor, 64, dstlen);
      runtest(srclen, (double)ifreq, factor, 32, dstlen);
      runtest(srclen, (double)ifreq, factor, 8, dstlen);
      runtest(srclen, (double)ifreq, factor, 2, dstlen);
      runtest(srclen, (double)ifreq, factor, srclen, dstlen);
   }

   printf("\n*** Vary dest block size ***\n\n");
   srclen = 10000;
   ifreq = 100;
   for(i=0; i<20; i++) {
      factor = ((rand() % 16) + 1) / 4.0;
      runtest(srclen, (double)ifreq, factor, srclen, 32);
      dstlen = (int)(srclen * factor + 10);
      runtest(srclen, (double)ifreq, factor, srclen, dstlen);
   }

   printf("\n*** Resample factor 1.0, testing different srclen ***\n\n");
   ifreq = 40;
   for(i=0; i<100; i++) {
      srclen = (rand() % 30000) + 10;
      dstlen = (int)(srclen + 10);
      runtest(srclen, (double)ifreq, 1.0, srclen, dstlen);
   }

   printf("\n*** Resample factor 1.0, testing different sin freq ***\n\n");
   srclen = 10000;
   for(i=0; i<100; i++) {
      ifreq = ((int)rand() % 10000) + 1;
      dstlen = (int)(srclen * 10);
      runtest(srclen, (double)ifreq, 1.0, srclen, dstlen);
   }

   printf("\n*** Resample with different factors ***\n\n");
   srclen = 10000;
   ifreq = 100;
   for(i=0; i<100; i++) {
      factor = ((rand() % 64) + 1) / 4.0;
      dstlen = (int)(srclen * factor + 10);
      runtest(srclen, (double)ifreq, factor, srclen, dstlen);
   }

   return 0;
}
Ejemplo n.º 9
0
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
	SaHpiRptEntryT res;
	SaHpiRdrT rdr;
	SaHpiEntryIdT id = SAHPI_FIRST_ENTRY;
	SaHpiResourceIdT resid;
	int failcount = 0;
	int testnum = 0;
	SaErrorT rc = SA_OK;

        rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
	if(rc != SA_OK) {
		failed("Failed to open session");
	}

	rc = saHpiDiscover(sid);
	if(rc != SA_OK) {
		failed("Failed to run discover");
	}
						
        rc = saHpiRptEntryGet(sid, id, &id, &res);
        runtest();
        if(rc != SA_OK) {
		dbg("Error %s",oh_lookup_error(rc));
		failed("Couldn't get the first rpt entry");
		/* we're toast, bail */
		goto end;
	}
	else{
		id = SAHPI_FIRST_ENTRY;
		resid = res.ResourceId;
		rc = saHpiRdrGet(sid, resid, id, &id, &rdr);
		if (oh_cmp_ep(&rdr.Entity,&res.ResourceEntity) != SAHPI_TRUE){
			dbg("Error %s", oh_lookup_error(rc));
			failed("Entity path of rdr did not match entity path of resource");
		}
		runtest();
		if(rc != SA_OK){
			dbg("Error %s", oh_lookup_error(rc));
			failed("Couldn't get the first rdr entry");
			goto end;
		}
	}
	
	dbg("Ran %d tests", testnum);
	/* if there is any failures, the test fails */
	end:
		if(failcount) {
			return -1;
		}

	return(0);
}
Ejemplo n.º 10
0
//
// Main program
//
int main(int argc, char *argv[])
{
	setbuf(stdout, NULL);

	long ranseq = 0;	// random stress test count
	long ranseed = 1;	// random seed for it

	int arg;
	while ((arg = getopt(argc, argv, "r:v")) != -1) {
		switch (arg) {
		case 'r': {
			ranseq = atoi(optarg);
			if (const char *colon = strchr(optarg, ':'))
				ranseed = atoi(colon + 1);
			else
				ranseed = getpid() ^ time(NULL);
			break;
			}
		case 'v':
			verbose = true;
			break;
		default:
			usage();
		}
	}
	if (optind < argc - 1)
		usage();
	const char *sequence = argv[optind];
	if (sequence && !strcmp(sequence, "+"))
		sequence = testCodes;
		
	if (ranseq) {	// repeated random (stress test) sequence
		if (!sequence)
			sequence = testCodes;
		printf("*** Random stress test: %ld iterations from <%s> with seed=%ld\n",
			ranseq, sequence, ranseed);
		srandom(ranseed);
		int setSize = strlen(sequence);
		for (long n = 0; n < ranseq; n++) {
			char type = sequence[random() % setSize];
			printf("\n[%ld:%c]", n, type);
			runtest(type);
		}
		printf("*** Random test sequence complete.\n");
		exit(0);
	} else {		// single-pass selected tests sequence
		if (!sequence)
			sequence = ".";	// default to ping test
		for (const char *s = sequence; *s; s++)
			runtest(*s);
		printf("*** Test sequence complete.\n");
		exit(0);
	}
}
int
main(void)
{
    int nf = 0;

    failed[0] = '\0';
    printf("Test bitvect_test: ");
    nf += runtest(boot, NULL, NULL);
    nf += runtest(oct_small_num, num_family_setup, num_family_teardown);
    nf += runtest(oct_large_num, num_family_setup, num_family_teardown);
    printf(" +%d-%d/3 %d%%\n%s",
           3-nf, nf, 100*(3-nf)/3, failed);
    return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
Ejemplo n.º 12
0
int main(int argc, char **argv)
{
	/* Initialisation */

	generate_wellknown_sids();

	/* Create security descriptor */

	sd = build_sec_desc(acl_printer, NULL, NULL_SID, NULL_SID);

	if (!sd) {
		printf("FAIL: could not build security descriptor\n");
		return 1;
	}

	/* Run test */

	runtest();

	/* Return */

        if (!failed) {
		printf("PASS\n");
		return 0;
	} 

	return 1;
}
Ejemplo n.º 13
0
static int dotest(int nchildren, int count, char **argv)
{
pid_t	p;
int	i;

	signal(SIGCHLD, SIG_DFL);

	for (i=0; i<nchildren; i++)
	{
		p=fork();
		if (p == -1)
		{
			perror("fork");
			cleanup();
			return (1);
		}
		if (p == 0)
		{
			close(1);
			if (open("/dev/null", O_WRONLY) != 1)
			{
				perror("open");
				exit(1);
			}
			exit(runtest(count, argv));
		}
	}

	return (cleanup());
}
Ejemplo n.º 14
0
Archivo: ftest03.c Proyecto: kraj/ltp
int main(int ac, char *av[])
{
	int lc;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		local_flag = PASSED;

		runtest();

		if (local_flag == PASSED) {
			tst_resm(TPASS, "Test passed.");
		} else {
			tst_resm(TFAIL, "Test failed.");
		}

		tst_rmdir();
		/* ??? so we are doing only one loop here ??? */
		tst_exit();
	}

	tst_exit();
}
Ejemplo n.º 15
0
ram_reply_t main2(int argc, char *argv[])
{
   ramtest_params_t testparams;
   ram_reply_t e = RAM_REPLY_INSANE;

   RAM_FAIL_TRAP(ram_initialize(NULL, NULL));

   RAM_FAIL_TRAP(initdefaults(&testparams));
   e = parseargs(&testparams, argc, argv);
   switch (e)
   {
   default:
      RAM_FAIL_TRAP(e);
   case RAM_REPLY_OK:
      break;
   case RAM_REPLY_INPUTFAIL:
      return e;
   }

   e = runtest(&testparams);
   switch (e)
   {
   default:
      RAM_FAIL_TRAP(e);
   case RAM_REPLY_OK:
      break;
   case RAM_REPLY_INPUTFAIL:
      return e;
   }

   return RAM_REPLY_OK;
}
Ejemplo n.º 16
0
int main(int argc, char **argv) {
    char *sta, *end;
    int argi = 1, testi;
     
    init_testcase();
     
    do {
	if (argi >= argc)
	    end = sta = NULL;
	else if (ISTEST(argv[argi]))
	    end = sta = argv[argi];
	else if (ISRANGE(argv[argi]))
	    end = (sta = argv[argi]) + 3;
	else {
	    fprintf(stderr, "invalid: %s\n", argv[argi]);
	    fprintf(stderr, "USAGE: ./test\n");
	    fprintf(stderr, " ./test [num] ...\n");
	    fprintf(stderr, " ./test [num]-[num] ...\n");
	    continue;
	}
	 
	for (testi = 0 ; testcase[testi] != NULL ; testi++) {
	    if (sta == NULL || end == NULL || (
			strncmp(sta, testcase[testi]->num, 2) <= 0 &&
			strncmp(end, testcase[testi]->num, 2) >= 0))
		 
		runtest(testcase[testi]);
	}
    } while (++argi < argc);
     
    return 0;
}
Ejemplo n.º 17
0
int runtests(char *dirname, char *ironout)
{
	struct dirent *ent;
	DIR *dir;
	int total = 0;
	int fails = 0;
	dir = opendir(dirname);
	if (!dir) {
		printf("failed: %s does not exist\n", dirname);
		return 1;
	}
	while ((ent = readdir(dir))) {
		char *name = ent->d_name;
		rmtempdir(".", 0);
		if (startswith(name, "test-") && !endswith(name, "~")) {
			char path[MAXPATHLEN];
			sprintf(path, "%s/%s", dirname, name);
			total++;
			if (runtest(path, ironout)) {
				fails++;
			}
		}
	}
	closedir(dir);
	if (fails)
		printf("\n%d of %d failed\n", fails, total);
	else
		printf("%d succeeded\n", total);
	return fails;
}
Ejemplo n.º 18
0
static int __init
init_crypto_wep_test(void)
{
	struct ieee80211com ic;
	struct ieee80211vap vap;
	int i, pass, total;

	memset(&ic, 0, sizeof(ic));
	memset(&vap, 0, sizeof(vap));
	vap.iv_ic = &ic;
	if (debug)
		vap.iv_debug = IEEE80211_MSG_CRYPTO;
	ieee80211_crypto_attach(&ic);
	ieee80211_crypto_vattach(&vap);
	pass = 0;
	total = 0;
	for (i = 0; i < ARRAY_SIZE(weptests); i++)
		if (tests & (1 << i)) {
			total++;
			pass += runtest(&vap, &weptests[i]);
		}
	printk("%u of %u 802.11i WEP test vectors passed\n", pass, total);
	ieee80211_crypto_vdetach(&vap);
	ieee80211_crypto_detach(&ic);
	return (pass == total ? 0 : -ENXIO);
}
Ejemplo n.º 19
0
int main(int ac, char *av[])
{
	int lc;
	char *msg;

	/*
	 * parse standard options
	 */
	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
		tst_resm(TBROK, "OPTION PARSING ERROR - %s", msg);
		tst_exit();
	}

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		local_flag = PASSED;
		init();
		runtest();

		if (local_flag == PASSED)
			tst_resm(TPASS, "Test passed.");
		else
			tst_resm(TFAIL, "Test failed.");
	}

	cleanup();
	tst_exit();
}
Ejemplo n.º 20
0
int main(int ac, char *av[])
{
	int lc;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		local_flag = PASSED;

		runtest();

		if (local_flag == PASSED)
			tst_resm(TPASS, "Test passed.");
		else
			tst_resm(TFAIL, "Test failed.");

		tst_rmdir();
		tst_exit();

	}

	tst_exit();
}
Ejemplo n.º 21
0
int main(int ac, char *av[])
{
	int lc;
	const char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		local_flag = PASSED;

		runtest();

		if (local_flag == PASSED) {
			tst_resm(TPASS, "Test passed.");
		} else {
			tst_resm(TFAIL, "Test failed.");
		}

		tst_rmdir();
		/* ??? so we are doing only one loop here ??? */
		tst_exit();
	}

	tst_exit();
}
Ejemplo n.º 22
0
Archivo: tx.c Proyecto: Artogn/picocoin
int main (int argc, char *argv[])
{
	runtest("tx3e0dc3da.json", "tx3e0dc3da.ser");

	bp_key_static_shutdown();
	return 0;
}
Ejemplo n.º 23
0
int main (int argc, char *argv[])
{
	runtest("wallet-basics.json", "tn_blk35133.ser",
	    "00000000003bf8f8f24e0c5f592a38bb7c18352745ef7192f1a576d855fd6b2d",
	    "bf1938abc33cc0b4cde7d94002412b17e35e3c657689e1be7ff588f3fda8d463");

	return 0;
}
Ejemplo n.º 24
0
int run_cuda(long *adbuffer)

{

	//runtest(adbuffer[]);
	return runtest(adbuffer);
       
}
Ejemplo n.º 25
0
Archivo: tester.c Proyecto: jre/upart
void
testfiles(FILE *idx)
{
	char *bad, *name, *fullname, *imgfile, *outfile, *errfile, *exitfile;
	char *newoutfile, *newerrfile;
	int exitval, failed, failures, testcount;
	size_t i;

	printf("running tests...\n");

	bad = NULL;
	testcount = 0;
	failures = 0;
	while ((name = nextname(TESTINDEX_PATH, idx)) != NULL) {
		for (i = 0; i < NITEMS(flags); i++) {
			fullname = strjoin(name, flags[i], (void *)NULL);
			imgfile = strjoin(name, ".img", (void *)NULL);
			outfile = strjoin(fullname, ".out", (void *)NULL);
			errfile = strjoin(fullname, ".err", (void *)NULL);
			exitfile = strjoin(fullname, ".exit", (void *)NULL);
			newoutfile = strjoin("test-", fullname, ".out", (void *)NULL);
			newerrfile = strjoin("test-", fullname, ".err", (void *)NULL);

			rmfile(newoutfile);
			rmfile(newerrfile);
			exitval = runtest(flags[i], imgfile,
			    newoutfile, newerrfile);
			failed = 0;

			if (!checkexitval(fullname, exitval, exitfile))
				failed = 1;
			if (!checkfiles(fullname, outfile, newoutfile, 0))
				failed = 1;
			if (!checkfiles(fullname, errfile, newerrfile, 1))
				failed = 1;

			testcount++;
			if (failed) {
				failures++;
				bad = appendname(bad, fullname);
			}

			free(fullname);
			free(imgfile);
			free(outfile);
			free(errfile);
			free(exitfile);
			free(newoutfile);
			free(newerrfile);
		}
	}

	printf("%d tests failed out of %d total.\n", failures, testcount);
	if (failures != 0) {
		printf("The following tests failed:\n  %s\n", bad);
		exit(EXIT_FAILURE);
	}
}
Ejemplo n.º 26
0
int main(int argc, char **argv)
{
        SaHpiSessionIdT sid = 0;
        SaHpiRptEntryT res;
        SaHpiEntryIdT id = SAHPI_FIRST_ENTRY;
        int failcount = 0;
        int testnum = 0;
        SaErrorT rc = SA_OK;

        rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
	if(rc != SA_OK) {
		failed("Failed to open session");
	}

	rc = saHpiDiscover(sid);
	if(rc != SA_OK) {
		failed("Failed to run discover");
	}
						
	
        /* loop over all resources, ensure that ResourceTag and
	 *            ManufacturerId have been set */
        while(saHpiRptEntryGet(sid,id,&id,&res) == SA_OK) {
		runtest();
		if(!res.ResourceTag.DataLength) {
			failed("Resource Tag has zero length");
		}
		runtest();
		if(!res.ResourceInfo.ManufacturerId) {
			failed("Resource has no Manufacturer Id");
		}

		/* there should be an inner loop here for Rdrs */
	}
 
 	printf("I hit here\n");	
	dbg("Ran %d tests", testnum);
        
	/* if there is any failures, the test fails */
	
        if(failcount) {
	                return -1;
		        }
        return(0);
}	
Ejemplo n.º 27
0
int main()
{
    for (int i = 0;i < 1000;i++) {
        if (i % 10 == 0)
            printf("Running: %d\n", i);
        runtest(1000000);
    }
    return 0;
}
Ejemplo n.º 28
0
int main (int argc, char *argv[])
{
	keytest_secp256k1();
	keytest();
	runtest();

	bp_key_static_shutdown();
	return 0;
}
Ejemplo n.º 29
0
int asyncMain(int argc, char**argv, bool loadvis) {
    void (*destroy)()=&nilDestroy;
    if (loadvis) {
        if (!loadedVis) {
            std::cerr<<"Failed to load vis library\n";
        } else {
            void (*init)();
            init=(void(*)())gVis.symbol("init");
            destroy=(void(*)())gVis.symbol("destroy");
            (*init)();
        }
    }
    {
        void (*init)();
        for (DevelopmentPluginMap::iterator i=gPlugins.begin(),ie=gPlugins.end(); i!=ie; ++i) {
            init=(void(*)())i->second->symbol("init");
            if (init)
                (*init)();
        }
    }

    Elysia::Vector3f test(0,1,2);
    std::tr1::unordered_map<Elysia::String,Elysia::Vector3f> bleh;
    bleh["ahoy"]=test;
    Elysia::Genome::Genome genes;
    if (argc>1) {
        if(0 == strcmp(argv[1],"-test")) {
            int retval= runtest();
            //int retval= Elysia::NNTest();
            printf("%d",retval);
            if (destroy)
                (*destroy)();
            destroyDevelopmentPlugins();
            return retval;
        }
        bool retval=loadFile(argv[1],genes);
        if (!retval) {
            printf("Error loading saved file\n");
        } else {
            printf("Success loading saved file\n");
        }
    }
    Elysia::Brain brain(&(new Elysia::SimpleProteinEnvironment)->initialize(genes), new Elysia::SimpleSpatialSearch);
    //std::vector<Branch *>BranchestoWipe;
    for (size_t i=0; i<1000; ++i) {
        brain.tick();
    }



    (*destroy)();
    destroyDevelopmentPlugins();


    return 0;
}
Ejemplo n.º 30
0
int main (int argc, char *argv[])
{
	const char *opn = GetOpName(OP_PUBKEY);
	assert(!strcmp(opn, "OP_PUBKEY"));

	opn = GetOpName(OP_INVALIDOPCODE);
	assert(!strcmp(opn, "OP_UNKNOWN"));

	runtest("data/blk120383.ser");

	bitc_key_static_shutdown();
	return 0;
}