TInt ParseCommandLine()
	{
	const TInt KMaxLineLength = 64;
	
	if (User::CommandLineLength() > KMaxLineLength)
		BadUsage();
	TBuf<KMaxLineLength> buffer;
	User::CommandLine(buffer);

	if (buffer == KNullDesC)
		return EActionTest;
	
	TLex lex(buffer);
	TInt result = 0;
	while (!lex.Eos())
		{
		TPtrC word = lex.NextToken();
		if (word == _L("test"))
			result |= EActionTest;
		else if (word == _L("thrashing"))
			result |= EActionThrashing;
		else if (word == _L("benchmarks"))
			result |= EActionBenchmarks;
		else
			{
			test.Printf(_L("bad token '%S'\n"), &word);
			BadUsage();
			}
		}
	
	return result;
	}
Exemple #2
0
int main(int argc, const char *argv[])
{
	yaffs_StartUp();
	if(argc == 3) {
		if(!strcmp(argv[2],"fw_update_init")){
			NorStressTestInitialise(argv[1]);
		}
		else if(!strcmp(argv[2],"fw_update")){
			NorStressTestRun(argv[1]);
		}
		else 
			BadUsage();
	}
	else
		BadUsage();
	return 0;
}
int main(int argc, char **argv)
{
	int ch;
	int random_mallocs=0;
	ext_fatal = test_fatal;

#if 1
	signal(SIGSEGV,bad_ptr_handler);
	signal(SIGBUS,bad_ptr_handler);
	signal(SIGABRT,bad_ptr_handler);
#endif	
	while ((ch = getopt(argc,argv, "bfilmn:ps:t:uz"))
	       != EOF)
		switch (ch) {
		case 's':
			random_seed = atoi(optarg);
			break;
		case 'p':
			simulate_power_failure =1;
			break;
		case 'i':
			init_test = 1;
			break;
		case 'b':
			do_bash_around = 1;
			break;
		case 'f':
			do_fsx = 1;
			break;
		case 'l':
			ops_multiplier *= 5;
			break;
		case 'u':
			do_upgrade = 1;
			break;
		case 'm':
			random_mallocs=1;
			break;
		case 'n':
			n_cycles = atoi(optarg);
			break;
		case 't':
			yaffs_traceMask = strtol(optarg,NULL,0);
			break;
		case 'z':fuzz_test=1;
			break;
		default:
			BadUsage();
			/* NOTREACHED */
		}
	argc -= optind;
	argv += optind;
	
	if(random_mallocs){
		yaffs_test_maxMallocs = 0xFFF & random_seed;
	}
	
	if(argc == 1) {
		int result;

		strcpy(mount_point,argv[0]);
		
		if(simulate_power_failure)
			n_cycles = -1;
		printf("Running test %s %s %s %s %s seed %d cycles %d\n",
			do_upgrade ? "fw_upgrade" : "",
			init_test ? "initialise":"",
			fuzz_test ? "fuzz-test" : "",
			do_fsx ? "fsx" :"",
			simulate_power_failure ? "power_fail" : "",
			random_seed, n_cycles);

		yaffs_StartUp();
		result = yaffs_mount(mount_point);
		if(result < 0){
			printf("Mount of %s failed\n",mount_point);
			printf("pid %d sleeping\n",getpid());
			
			while(!sleep_exit){
				sleep(1);
				sleep_time++;
			}
		}
		printf("Mount complete\n");
			
		if(do_upgrade && init_test){
			simulate_power_failure = 0;
			NorStressTestInitialise(mount_point);
		} else if(do_upgrade){
			printf("Running stress on %s with seed %d\n",mount_point,random_seed);
			NorStressTestRun(mount_point,n_cycles,do_fsx,fuzz_test);
		} else if(do_fsx){
			yaffs_fsx_main(mount_point,n_cycles);
		} else if(do_bash_around){
			yaffs_bash_around(mount_point,n_cycles);
		}else {
			printf("No test to run!\n");
			BadUsage();
		}
		yaffs_unmount(mount_point);
		
		printf("Test run completed!\n");
	}
	else
		BadUsage();
	return 0;
}