Exemple #1
0
void do_leave_program (void)
{
	sampler_free ();
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free ();
#endif
#ifdef A2091
	a2091_free ();
	a3000scsi_free ();
#endif
#ifdef NCR
	ncr710_free();
	ncr_free();
#endif
#ifdef NCR9X
	ncr9x_free();
#endif
#ifdef CD32
	akiko_free ();
	cd32_fmv_free();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
	gayle_free ();
	device_func_reset ();
#ifdef WITH_LUA
	uae_lua_free ();
#endif
	savestate_free ();
	memory_cleanup ();
	free_shm ();
	cfgfile_addcfgparam (0);
	machdep_free ();
}
Exemple #2
0
void do_leave_program (void)
{
#ifdef SAMPLER
	sampler_free ();
#endif
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free ();
#endif
#ifdef A2091
	a2091_free ();
#endif
#ifdef NCR
	ncr_free ();
#endif
#ifdef CD32
	akiko_free ();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
#ifdef SCSIEMU
#ifdef GAYLE
	gayle_free ();
#endif
	device_func_reset ();
#endif
	savestate_free ();
	memory_cleanup ();
#ifdef NATMEM_OFFSET
	free_shm ();
#endif
	cfgfile_addcfgparam (0);
	machdep_free ();
}
Exemple #3
0
int attempt(int *rip, int *count, unsigned char *P, int m, unsigned char*T, int n,
			char *algoname, key_t pkey, key_t tkey, key_t rkey, key_t ekey, key_t prekey,
			int alpha, char *parameter, int ncase) {
	(*rip)++;
	//printf("\b\b\b\b\b\b[%.3d%%]",(*rip)*100/18); fflush(stdout);
	(*count) = 0;
	int occur1 = search(P,m,T,n);
	int occur2 = execute(algoname,pkey,m,tkey,n,rkey,ekey,prekey,count,alpha);
	if(occur2>=0 && occur1 != occur2) {
		if(!VERBOSE) printf("\n\tERROR: test failed on case n.%d (\"%s\" in \"%s\")\n\
							found %d occ instead of %d\n\n", ncase,P,T,occur2,occur1);
		free_shm();
		return 0;
	}
	return 1;
}
Exemple #4
0
/* Hash test: buffer of size byte. Run test n times. */
static void run_test(size_t size, unsigned int n, unsigned int l)
{
	uint64_t t;
	struct statistics stats;
	TEEC_Operation op;
	int n0 = n;

	alloc_shm(size, algo);

	if (!random_in)
		memset((uint8_t *)in_shm.buffer + offset, 0, size);

	memset(&op, 0, sizeof(op));
	op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_PARTIAL_INPUT,
					 TEEC_MEMREF_PARTIAL_OUTPUT,
					 TEEC_VALUE_INPUT, TEEC_NONE);
	op.params[0].memref.parent = &in_shm;
	op.params[0].memref.offset = 0;
	op.params[0].memref.size = size + offset;
	op.params[1].memref.parent = &out_shm;
	op.params[1].memref.offset = 0;
	op.params[1].memref.size = hash_size(algo);
	op.params[2].value.a = l;
	op.params[2].value.b = offset;

	verbose("Starting test: %s, size=%zu bytes, ",
		algo_str(algo), size);
	verbose("random=%s, ", yesno(random_in));
	verbose("unaligned=%s, ", yesno(offset));
	verbose("inner loops=%u, loops=%u, warm-up=%u s\n", l, n, warmup);

	if (warmup)
		do_warmup();

	memset(&stats, 0, sizeof(stats));
	while (n-- > 0) {
		t = run_test_once((uint8_t *)in_shm.buffer + offset, size, &op, l);
		update_stats(&stats, t);
		if (n % (n0/10) == 0)
			vverbose("#");
	}
	vverbose("\n");
	printf("min=%gμs max=%gμs mean=%gμs stddev=%gμs (%gMiB/s)\n",
	       stats.min/1000, stats.max/1000, stats.m/1000,
	       stddev(&stats)/1000, mb_per_sec(size, stats.m));
	free_shm();
}
Exemple #5
0
void do_leave_program (void)
{
	sampler_free ();
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef PARALLEL_PORT
	parallel_exit();
#endif
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free();
	cdtvcr_free();
#endif
#ifdef A2091
	a2091_free ();
	gvp_free ();
	a3000scsi_free ();
#endif
	soft_scsi_free();
#ifdef NCR
	ncr_free();
#endif
#ifdef NCR9X
	ncr9x_free();
#endif
#ifdef CD32
	akiko_free ();
	cd32_fmv_free();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef WITH_PCI
	pci_free();
#endif
#ifdef WITH_X86
	x86_bridge_free();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
	gayle_free ();
	idecontroller_free();
	device_func_reset ();
#ifdef WITH_LUA
	uae_lua_free ();
#endif
#ifdef WITH_PPC
	uae_ppc_free();
#endif
#ifdef WITH_TOCCATA
	sndboard_free();
#endif
	gfxboard_free();
#ifdef SAVESTATE
	savestate_free ();
#endif
	memory_cleanup ();
	free_shm ();
	cfgfile_addcfgparam (0);
	machdep_free ();
#ifdef DRIVESOUND
	driveclick_free();
#endif
	ethernet_enumerate_free();
}
Exemple #6
0
int main(int argc, char *argv[]) {
	int i, j;
	
	/* processing of input parameters */
	if (argc==1) {printManual(); return 0;}
	char algoname[100];
	strcpy(algoname,argv[1]);
	char parameter[100];
	if(argc>2) strcpy(parameter,argv[2]);
	char filename[100] = "source/bin/";
	strcat(filename,algoname);
	FILE *fp = fopen(filename, "r");
	if( !fp ) {
		if(!VERBOSE) printf("\n\tERROR: unable to execute program %s\n\n",filename);
		exit(1);
	}
	fclose(fp);
	
   	//allocate space for text in shered memory
   	srand( time(NULL) );
   	key_t tkey = rand()%1000;
    int try = 0;
    do  {
		tkey = rand()%1000;
		tshmid = shmget(tkey, YSIZE*2, IPC_CREAT | 0666); 
 	} while(++try<ATTEMPT && tshmid<0);
    if (tshmid < 0) {
        perror("shmget"); 
		exit(1);
    }
   	if ((T = shmat(tshmid, NULL, 0)) == (unsigned char *) -1) {
   	    perror("shmat"); 
		free_shm();
		exit(1);
   	}

	//allocate space for running time in shered memory
	srand( time(NULL) );
	key_t ekey = rand()%1000;
	try = 0;
	do {
		ekey = rand()%1000; 
		eshmid = shmget(ekey, 8, IPC_CREAT | 0666); 
	} while((++try<ATTEMPT && eshmid<0) || ekey==tkey);
	if (eshmid < 0) {
		perror("shmget"); 
		free_shm();
		exit(1);
	}
	if ((e_time = shmat(eshmid, NULL, 0)) == (double *) -1) {
		perror("shmat"); 
		free_shm();
		exit(1);
	}


   //allocate space for preprocessing running time in shered memory
   key_t prekey = rand()%1000;
   try = 0;
   do {
		prekey = rand()%1000; 
		preshmid = shmget(prekey, 8, IPC_CREAT | 0666); 
   } while((++try<ATTEMPT && preshmid<0) || prekey==tkey || prekey==ekey);
   if (preshmid < 0) {
       perror("shmget"); 
	   free_shm();
	   exit(1);
   }
   if ((pre_time = shmat(preshmid, NULL, 0)) == (double *) -1) {
       perror("shmat"); 
  	   free_shm();
	   exit(1);
   }
   for(i=0; i<SIGMA; i++) FREQ[i] = 0;


	//allocate space for pattern in shered memory
   key_t pkey = rand()%1000;
   try = 0;
   do {
		pkey = rand()%1000; 
		pshmid = shmget(pkey, XSIZE+1, IPC_CREAT | 0666); 
   } while((++try<ATTEMPT && pshmid<0) || pkey==tkey || pkey==ekey || pkey==prekey);
   if (pshmid < 0) {
       perror("shmget"); 
	   free_shm();
	   exit(1);
   }
   if ((P = shmat(pshmid, NULL, 0)) == (unsigned char *) -1) {
       perror("shmat"); 
   	   free_shm();
	   exit(1);
   }
   for(i=0; i<SIGMA; i++) FREQ[i] = 0;

   //allocate space for the result number of occurrences in shared memory
   int *count;
   key_t rkey = rand()%1000;
   try = 0;
   do  {
		rkey = rand()%1000; 
		rshmid = shmget(rkey, 4, IPC_CREAT | 0666); 
   } while((++try<ATTEMPT && rshmid<0) || rkey==tkey || rkey==pkey || pkey==ekey || pkey==prekey);
   if (rshmid < 0) {
       perror("shmget"); 
       free_shm();
	   exit(1);
   }
   if ((count = shmat(rshmid, NULL, 0)) == (int *) -1) {
       perror("shmat"); 
	   free_shm();
	   exit(1);
   }

	if(!VERBOSE) printf("\n\tPlease, wait a moment..............");
	fflush(stdout);

	//begin testing
	int rip = 0;
	int alpha, k, h, m, occur1, occur2, test=1;
	/*for(alpha = 2; alpha<=128; alpha*=2) {
		for(i=0; i<YSIZE; i++) T[i] = rand()%alpha;
		// compute the frequency of characters
		//for(j=0; j<SIGMA; j++) FREQ[j]=0;
		//for(j=0; j<YSIZE; j++) FREQ[T[j]]++;
		for(m = 2; m<=16; m*=2) {
			for(j=0; j<10; j++) {
				rip++;
				printf("\b\b\b\b\b\b[%.3d%%]",rip*10/28); fflush(stdout);
				(*count) = 0;
				k = j*2;
				for(h=0; h<m; h++) P[h] = T[k+h];
				P[m]='\0';
				occur1 = search(P,m,T,YSIZE);
	        	occur2 = execute(algoname,pkey,m,tkey,YSIZE,rkey,ekey,prekey,count,alpha);
				if(occur2>=0 && occur1 != occur2) {
					if(!VERBOSE) printf("\n\tERROR: test failed\n\n");
					free_shm();
					exit(1);
				}
			}
		}
	}*/
	
	// 1) search for "a" in "aaaaaaaaaa"
	strcpy((char*)P,"a");
	strcpy((char*)T,"aaaaaaaaaa");
	if(!attempt(&rip,count,P,1,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,1))
		exit(1);

	// 2) search for "aa" in "aaaaaaaaaa"
	strcpy((char*)P,"aa");
	strcpy((char*)T,"aaaaaaaaaa");
	if(!attempt(&rip,count,P,2,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,2))
		exit(1);

	// 3) search for "aaaaaaaaaa" in "aaaaaaaaaa"
	strcpy((char*)P,"aaaaaaaaaa");
	strcpy((char*)T,"aaaaaaaaaa");
	if(!attempt(&rip,count,P,10,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,3))
		exit(1);

	// 4) search for "b" in "aaaaaaaaaa"
	strcpy((char*)P,"b");
	strcpy((char*)T,"aaaaaaaaaa");
	if(!attempt(&rip,count,P,1,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,4))
		exit(1);

	// 5) search for "abab" in "ababababab"
	strcpy((char*)P,"ab");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,2,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,5))
		exit(1);

	// 6) search for "a" in "ababababab"
	strcpy((char*)P,"a");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,1,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,6))
		exit(1);

	// 7) search for "aba" in "ababababab"
	strcpy((char*)P,"aba");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,3,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,7))
		exit(1);

	// 8) search for "abc" in "ababababab"
	strcpy((char*)P,"abc");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,3,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,8))
		exit(1);

	// 9) search for "ba" in "ababababab"
	strcpy((char*)P,"ba");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,2,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,8))
		exit(1);

	// 10) search for "babbbbb" in "ababababab"
	strcpy((char*)P,"babbbbb");
	strcpy((char*)T,"ababababab");
	if(!attempt(&rip,count,P,7,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,10))
		exit(1);

	// 11) search for "bcdefg" in "bcdefghilm"
	strcpy((char*)P,"bcdefg");
	strcpy((char*)T,"bcdefghilm");
	if(!attempt(&rip,count,P,6,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,11))
		exit(1);

	// 12) search for rand in rand
	for(h=0; h<10; h++) T[h] = rand()%128;
	for(h=0; h<4; h++) P[h] = T[h];
	T[YSIZE] = P[4] = '\0';
	if(!attempt(&rip,count,P,4,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,12))
		exit(1);

	// 13) search for rand in rand
	for(h=0; h<10; h++) T[h] = rand()%128;
	for(h=0; h<4; h++) P[h] = T[h];
	T[10] = P[4] = '\0';
	if(!attempt(&rip,count,P,4,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,13))
		exit(1);

	// 14) search for rand in rand
	for(h=0; h<64; h++) T[h] = rand()%128;
	for(h=0; h<40; h++) P[h] = T[h];
	T[64] = P[40] = '\0';
	if(!attempt(&rip,count,P,40,T,64,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,14))
		exit(1);

	// 15) search for rand in rand
	for(h=0; h<64; h++) T[h] = rand()%128;
	for(h=0; h<40; h++) P[h] = T[h];
	T[64] = P[40] = '\0';
	if(!attempt(&rip,count,P,40,T,64,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,15))
		exit(1);

	// 16) search for rand in rand
	for(h=0; h<64; h++) T[h] = 'a';
	for(h=0; h<40; h++) P[h] = 'a';
	T[64] = P[40] = '\0';
	if(!attempt(&rip,count,P,40,T,64,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,16))
		exit(1);

	// 17) search for rand in rand
	for(h=0; h<64; h+=2) T[h] = 'a';
	for(h=1; h<64; h+=2) T[h] = 'b';
	for(h=0; h<40; h+=2) P[h] = 'a';
	for(h=1; h<40; h+=2) P[h] = 'b';
	T[64] = P[40] = '\0';
	if(!attempt(&rip,count,P,40,T,64,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,17))
		exit(1);

	// 18) search for rand in rand
	for(h=0; h<64; h+=2) T[h] = 'a';
	for(h=1; h<64; h+=2) T[h] = 'b';
	for(h=0; h<40; h+=2) P[h] = 'a';
	for(h=1; h<40; h+=2) P[h] = 'b';
	P[39] = 'c';
	T[64] = P[40] = '\0';
	if(!attempt(&rip,count,P,40,T,64,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,18))
		exit(1);

    // 19) search for "babbbbb" in "abababbbbb"
    strcpy((char*)P,"babbbbb");
    strcpy((char*)T,"abababbbbb");
    if(!attempt(&rip,count,P,7,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,19))
        exit(1);

    // 20) search for "bababb" in "abababbbbb"
    strcpy((char*)P,"bababb");
    strcpy((char*)T,"abababbbbb");
    if(!attempt(&rip,count,P,6,T,10,algoname,pkey,tkey,rkey,ekey,prekey,alpha,parameter,20))
        exit(1);
    	
	if(!VERBOSE) printf("\n\tWell done! Test passed successfully\n\n");
		

   	//free shared memory
   	free_shm();
	return 0;
}