Beispiel #1
0
int main(int argc, const char* argv[])
{
	bool fullLog = false;
	bool useJit = true;
	bool autoCompare = false;
	bool useGraphics = false;
	
	const char *bootFilename = 0;
	const char *mountIso = 0;
	const char *screenshotFilename = 0;
	bool readMount = false;

	for (int i = 1; i < argc; i++)
	{
		if (readMount)
		{
			mountIso = argv[i];
			readMount = false;
			continue;
		}
		if (!strcmp(argv[i], "-m") || !strcmp(argv[i], "--mount"))
			readMount = true;
		else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log"))
			fullLog = true;
		else if (!strcmp(argv[i], "-i"))
			useJit = false;
		else if (!strcmp(argv[i], "-j"))
			useJit = true;
		else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--compare"))
			autoCompare = true;
		else if (!strcmp(argv[i], "--graphics"))
			useGraphics = true;
		else if (!strncmp(argv[i], "--screenshot=", strlen("--screenshot=")) && strlen(argv[i]) > strlen("--screenshot="))
			screenshotFilename = argv[i] + strlen("--screenshot=");
		else if (bootFilename == 0)
			bootFilename = argv[i];
		else
		{
			if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
				printUsage(argv[0], NULL);
			else
			{
				std::string reason = "Unexpected argument " + std::string(argv[i]);
				printUsage(argv[0], reason.c_str());
			}
			return 1;
		}
	}

	if (readMount)
	{
		printUsage(argv[0], "Missing argument after -m");
		return 1;
	}
	if (!bootFilename)
	{
		printUsage(argv[0], argc <= 1 ? NULL : "No executable specified");
		return 1;
	}

	HeadlessHost *headlessHost = useGraphics ? new HEADLESSHOST_CLASS() : new HeadlessHost();
	host = headlessHost;

	std::string error_string;
	bool glWorking = host->InitGL(&error_string);

	LogManager::Init();
	LogManager *logman = LogManager::GetInstance();
	
	PrintfLogger *printfLogger = new PrintfLogger();

	for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
	{
		LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
		logman->SetEnable(type, fullLog);
		logman->SetLogLevel(type, LogTypes::LDEBUG);
		logman->AddListener(type, printfLogger);
	}

	CoreParameter coreParameter;
	coreParameter.cpuCore = useJit ? CPU_JIT : CPU_INTERPRETER;
	coreParameter.gpuCore = glWorking ? GPU_GLES : GPU_NULL;
	coreParameter.enableSound = false;
	coreParameter.fileToStart = bootFilename;
	coreParameter.mountIso = mountIso ? mountIso : "";
	coreParameter.startPaused = false;
	coreParameter.enableDebugging = false;
	coreParameter.printfEmuLog = true;
	coreParameter.headLess = true;
	coreParameter.renderWidth = 480;
	coreParameter.renderHeight = 272;
	coreParameter.outputWidth = 480;
	coreParameter.outputHeight = 272;
	coreParameter.pixelWidth = 480;
	coreParameter.pixelHeight = 272;
	coreParameter.unthrottle = true;

	g_Config.bEnableSound = false;
	g_Config.bFirstRun = false;
	g_Config.bIgnoreBadMemAccess = true;
	// Never report from tests.
	g_Config.sReportHost = "";
	g_Config.bAutoSaveSymbolMap = false;
	g_Config.iRenderingMode = true;
	g_Config.bHardwareTransform = true;
#ifdef USING_GLES2
	g_Config.iAnisotropyLevel = 0;
#else
	g_Config.iAnisotropyLevel = 8;
#endif
	g_Config.bVertexCache = true;
	g_Config.bTrueColor = true;
	g_Config.ilanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
	g_Config.iTimeFormat = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
	g_Config.bEncryptSave = true;
	g_Config.sNickName = "shadow";
	g_Config.iTimeZone = 60;
	g_Config.iDateFormat = PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY;
	g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CROSS;
	g_Config.iLockParentalLevel = 9;

#if defined(ANDROID)
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
#elif !defined(_WIN32)
	g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/";
	g_Config.flashDirectory = g_Config.memCardDirectory+"/flash/";
#endif

	if (!PSP_Init(coreParameter, &error_string)) {
		fprintf(stderr, "Failed to start %s. Error: %s\n", coreParameter.fileToStart.c_str(), error_string.c_str());
		printf("TESTERROR\n");
		return 1;
	}

	host->BootDone();

	if (screenshotFilename != 0)
		headlessHost->SetComparisonScreenshot(screenshotFilename);

	coreState = CORE_RUNNING;
	while (coreState == CORE_RUNNING)
	{
		int blockTicks = usToCycles(1000000 / 10);
		PSP_RunLoopFor(blockTicks);

		// If we were rendering, this might be a nice time to do something about it.
		if (coreState == CORE_NEXTFRAME) {
			coreState = CORE_RUNNING;
			headlessHost->SwapBuffers();
		}
	}

	host->ShutdownGL();
	PSP_Shutdown();

	delete host;
	host = NULL;
	headlessHost = NULL;

	if (autoCompare)
		CompareOutput(bootFilename);

	return 0;
}
Beispiel #2
0
int main(int argc, const char* argv[])
{
	bool fullLog = false;
	bool useJit = true;
	bool autoCompare = false;
	bool useGraphics = false;
	
	const char *bootFilename = 0;
	const char *mountIso = 0;
	const char *screenshotFilename = 0;
	bool readMount = false;

	for (int i = 1; i < argc; i++)
	{
		if (readMount)
		{
			mountIso = argv[i];
			readMount = false;
			continue;
		}
		if (!strcmp(argv[i], "-m") || !strcmp(argv[i], "--mount"))
			readMount = true;
		else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log"))
			fullLog = true;
		else if (!strcmp(argv[i], "-i"))
			useJit = false;
		else if (!strcmp(argv[i], "-j"))
			useJit = true;
		else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--compare"))
			autoCompare = true;
		else if (!strcmp(argv[i], "--graphics"))
			useGraphics = true;
		else if (!strncmp(argv[i], "--screenshot=", strlen("--screenshot=")) && strlen(argv[i]) > strlen("--screenshot="))
			screenshotFilename = argv[i] + strlen("--screenshot=");
		else if (bootFilename == 0)
			bootFilename = argv[i];
		else
		{
			if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
				printUsage(argv[0], NULL);
			else
			{
				std::string reason = "Unexpected argument " + std::string(argv[i]);
				printUsage(argv[0], reason.c_str());
			}
			return 1;
		}
	}

	if (readMount)
	{
		printUsage(argv[0], "Missing argument after -m");
		return 1;
	}
	if (!bootFilename)
	{
		printUsage(argv[0], argc <= 1 ? NULL : "No executable specified");
		return 1;
	}

	HeadlessHost *headlessHost = useGraphics ? new HEADLESSHOST_CLASS() : new HeadlessHost();
	host = headlessHost;

	std::string error_string;
	host->InitGL(&error_string);

	LogManager::Init();
	LogManager *logman = LogManager::GetInstance();
	
	PrintfLogger *printfLogger = new PrintfLogger();

	for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
	{
		LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
		logman->SetEnable(type, fullLog);
		logman->SetLogLevel(type, LogTypes::LDEBUG);
		logman->AddListener(type, printfLogger);
	}

	CoreParameter coreParameter;
	coreParameter.fileToStart = bootFilename;
	coreParameter.mountIso = mountIso ? mountIso : "";
	coreParameter.startPaused = false;
	coreParameter.cpuCore = useJit ? CPU_JIT : CPU_INTERPRETER;
	coreParameter.gpuCore = headlessHost->isGLWorking() ? GPU_GLES : GPU_NULL;
	coreParameter.enableSound = false;
	coreParameter.headLess = true;
	coreParameter.printfEmuLog = true;
	coreParameter.useMediaEngine = false;

	g_Config.bEnableSound = false;
	g_Config.bFirstRun = false;
	g_Config.bIgnoreBadMemAccess = true;
	// Never report from tests.
	g_Config.sReportHost = "";

#if defined(ANDROID)
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
#elif !defined(_WIN32)
	g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/";
	g_Config.flashDirectory = g_Config.memCardDirectory+"/flash/";
#endif


	if (!PSP_Init(coreParameter, &error_string)) {
		fprintf(stderr, "Failed to start %s. Error: %s\n", coreParameter.fileToStart.c_str(), error_string.c_str());
		printf("TESTERROR\n");
		return 1;
	}

	host->BootDone();

	if (screenshotFilename != 0)
		headlessHost->SetComparisonScreenshot(screenshotFilename);

	coreState = CORE_RUNNING;
	while (coreState == CORE_RUNNING)
	{
		// Run for a frame at a time, just because.
		u64 nowTicks = CoreTiming::GetTicks();
		u64 frameTicks = usToCycles(1000000/60);
		mipsr4k.RunLoopUntil(nowTicks + frameTicks);

		// If we were rendering, this might be a nice time to do something about it.
		if (coreState == CORE_NEXTFRAME) {
			coreState = CORE_RUNNING;
			headlessHost->SwapBuffers();
		}
	}

	host->ShutdownGL();
	PSP_Shutdown();

	delete host;
	host = NULL;
	headlessHost = NULL;

	if (autoCompare)
		CompareOutput(bootFilename);

	return 0;
}
Beispiel #3
0
bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool autoCompare, bool verbose, double timeout)
{
	if (teamCityMode) {
		// Kinda ugly, trying to guesstimate the test name from filename...
		teamCityName = GetTestName(coreParameter.fileToStart);
	}

	std::string output;
	if (autoCompare)
		coreParameter.collectEmuLog = &output;

	std::string error_string;
	if (!PSP_Init(coreParameter, &error_string)) {
		fprintf(stderr, "Failed to start %s. Error: %s\n", coreParameter.fileToStart.c_str(), error_string.c_str());
		printf("TESTERROR\n");
		TeamCityPrint("##teamcity[testIgnored name='%s' message='PRX/ELF missing']\n", teamCityName.c_str());
		return false;
	}

	TeamCityPrint("##teamcity[testStarted name='%s' captureStandardOutput='true']\n", teamCityName.c_str());

	host->BootDone();

	if (autoCompare)
		headlessHost->SetComparisonScreenshot(ExpectedScreenshotFromFilename(coreParameter.fileToStart));

	time_update();
	bool passed = true;
	// TODO: We must have some kind of stack overflow or we're not following the ABI right.
	// This gets trashed if it's not static.
	static double deadline;
	deadline = time_now() + timeout;

	coreState = CORE_RUNNING;
	while (coreState == CORE_RUNNING)
	{
		int blockTicks = usToCycles(1000000 / 10);
		PSP_RunLoopFor(blockTicks);

		// If we were rendering, this might be a nice time to do something about it.
		if (coreState == CORE_NEXTFRAME) {
			coreState = CORE_RUNNING;
			headlessHost->SwapBuffers();
		}
		time_update();
		if (time_now_d() > deadline) {
			// Don't compare, print the output at least up to this point, and bail.
			printf("%s", output.c_str());
			passed = false;

			host->SendDebugOutput("TIMEOUT\n");
			TeamCityPrint("##teamcity[testFailed name='%s' message='Test timeout']\n", teamCityName.c_str());
			Core_Stop();
		}
	}

	PSP_Shutdown();

	headlessHost->FlushDebugOutput();

	if (autoCompare && passed)
		passed = CompareOutput(coreParameter.fileToStart, output, verbose);

	TeamCityPrint("##teamcity[testFinished name='%s']\n", teamCityName.c_str());

	return passed;
}
void CVJDecompressTypeErrorTest::ProcessPacketL()
/**
This is a virtual function. 
This function feeds precompressed IP/TCP packets into both 
the VJDeCompressor (unit under test) and the Referece Decompressor 
(provided in RFC 1144).
The output of the VJDeCompressor is compared against the output of 
the Reference Decompressor to verify its corectness 
*/

{	
		TUint packetType = TrimPacketBeforeDecompression();
		
		if (packetType == 911)
		{
		    // Packet type is unsupported. Abort test.
		    SetTestStepResult(EFail);
		    return;
		}
			
		// Create packet buffer to be sent to reference decompressor
		// This is to prevent compromising the test results if the compressor/decompressor alters the original data
	    HBufC8* refPacketBuffer = HBufC8::NewMaxLC(TPcapRecord::KMaxPacketSize+KRefPacketHeaderSpace);
	    // Reserve some space at the head of the HBufC8 for the uncompressed header
	    // The reference decompressor expects the packet has enough space to prepend 120 byes of resconstructed header 
	    TPtr8 refInputPtr(const_cast<TUint8*>(refPacketBuffer->Ptr())+KRefPacketHeaderSpace, refPacketBuffer->Length()-KRefPacketHeaderSpace);
	    refInputPtr = iRec->Data();
	    
	    TUint8 *refdecompOutput = NULL;
	    TInt refPacketLen = refInputPtr.Length();
	  
	    // Create packet buffer to be sent to VJDecompressor
	    // This is to prevent compromising the test results if the compressor/decompressor alters the original data
	    // The size of the HBuf object must have a maximum length that is big enough to hold the decompressed data
	    HBufC8* vjPacketBuffer = HBufC8::NewLC(TPcapRecord::KMaxPacketSize);
	    TPtr8 vjOutputPtr (vjPacketBuffer->Des());
	    vjOutputPtr = iRec->Data();
	    		  
	    iPacket.CopyIn(*vjPacketBuffer, 0); 
	    iPacket.TrimEnd(vjPacketBuffer->Length());
		 
	   
	    // Create info packet
 	    RMBufPacket pkt;
	    RMBufPktInfo* info = 0;
        info = pkt.NewInfoL();  
       	info->iLength = vjPacketBuffer->Length();
        pkt.Pack();
        iPacket.Prepend(pkt);
	    		
	    // Put info packet in front of this packet 
	    TUint vjdecompRet;
	    
	     //-------------- substep 7 -------------------- 
	    // decompress the packet using VJDeCompressor and Reference decompressor 
	    INFO_PRINTF1(_L("  07, 08 Decompress the packet using VJDeCompressor and Reference Decompressor:"));
	    
	    switch (packetType)
	    {
	        case KPppIdIp:
	        // the packet is TYPE_IP
	             // decompress TYPE_IP packet using our reference decompressor
	            INFO_PRINTF1(_L("  07 Decompress TYPE_IP packet using reference decompressor:"));
      			refdecompOutput = sl_uncompress_tcp(const_cast<TUint8*>(refInputPtr.Ptr()), &refPacketLen, (TUint)TYPE_IP, iComp);
	    
	            // VJ Decompressor function is not called because the packet is TYPE_IP
	            INFO_PRINTF1(_L("  08 TYPE_IP packet is not modified by VJDecompressor."));
	            vjdecompRet = ETrue;
	    		break;
  		    case KPppIdVjCompTcp:
	        // the packet is COMPRESSED_TCP
	            // decompress using our reference decompressor
	            INFO_PRINTF1(_L("  07 Decompress COMPRESSED_TCP packet using reference decompressor:"));
      			refdecompOutput = sl_uncompress_tcp(const_cast<TUint8*>(refInputPtr.Ptr()), &refPacketLen, (TUint)TYPE_COMPRESSED_TCP, iComp);
	        
                //decompress using our VJ Decompressor
	            INFO_PRINTF1(_L("  08 Decompress COMPRESSED_TCP packet using VJDeCompressor:"));
	            vjdecompRet = iVJDeCompressor->DecompVJComp(iPacket);
	            INFO_PRINTF2(_L(" 08 COMPRESSED_TCP packet is decompressed: %d"), vjdecompRet);
	   	  		break;
	        case KPppIdVjUncompTcp:
	        // the packet is UNCOMPRESSED_TCP
	            // decompress using our reference Compressor
	            INFO_PRINTF1(_L("  07 Decompress UNCOMPRESSED_TCP packet using reference decompressor:"));
      			refdecompOutput = sl_uncompress_tcp(const_cast<TUint8*>(refInputPtr.Ptr()), &refPacketLen, (TUint)TYPE_UNCOMPRESSED_TCP, iComp);
	        	
	        //decompress using our VJ Decompressor
	            INFO_PRINTF1(_L("  08 Decompress UNCOMPRESSED_TCP packet using VJDeCompressor:"));
	            vjdecompRet = iVJDeCompressor->DecompVJUncomp(iPacket);
	            INFO_PRINTF2(_L(" 08 UNCOMPRESSED_TCP packet is decompressed: %d"), vjdecompRet);
	        	break;
	        default: 
	        //the packet is TYPE_ERROR
	            // set 'toss' flag and discard COMPRESSED_TCP packet until one with C bit set
	            // or an UNCOMPRESSED_TCP packet arrives
	             // decompress using our reference decompressor
	            INFO_PRINTF1(_L("  07 Decompress TYPE_ERROR packet using reference decompressor:"));
      			refdecompOutput = sl_uncompress_tcp(const_cast<TUint8*>(refInputPtr.Ptr()), &refPacketLen, (TUint)TYPE_ERROR, iComp);
	     		//decompress using our VJ Decompressor
	            INFO_PRINTF1(_L("  08 Handle TYPE_ERROR packet using VJDeCompressor:"));
	            iVJDeCompressor->CRCError(); 
	            vjdecompRet = EFalse;
	    		break;
	    }    
	    
	     if ((vjdecompRet) && refdecompOutput != 0)
	     {
	         //--------------substep 09----------------------
 	         // Display VJ decompressed packet
	         INFO_PRINTF1(_L("  09 The VJ decompressed packet:"));
	     
	         // The decompressed data should be larger than the compressed data
	         // So we need to expand the size of the pointer in order to hold the decompressed data
	         vjOutputPtr.SetMax();
	         
	         // Remove info packet 
	         iPacket.Remove();
	         iPacket.CopyOut(vjOutputPtr);	
 			 
	         INFO_PRINTF2(_L("VJ decompressed packet len: %d"), vjPacketBuffer->Length()); 
	         // TPtrC8 object is created because DumpIp() takes a TPtrC8 object as a parameter
	         TPtrC8 vjOutputPtrC (vjOutputPtr);
	         DumpIp(vjOutputPtrC);
	     
	         //--------------substep 10----------------------
 	         // Display REF decompressed packet
	         INFO_PRINTF1(_L("10 The REF decompressed packet is:")); 
	         TPtrC8 refOutputPtrC(refdecompOutput, refPacketLen);
	         DumpIp(refOutputPtrC);
	         
 	         //--------------substep 11----------------------
 	         //Compare the results of the reference compressor output and our VJ compressor output
 	     
 	         INFO_PRINTF1(_L("  11 Compare the result of the compression by VJCompressor to Reference compressor:"));
 	         INFO_PRINTF2(_L(" Size of VJ comp output: %d"), vjOutputPtrC.Length()); 
 		     INFO_PRINTF2(_L(" Size of Reference comp output: %d"), refOutputPtrC.Length()); 
 	     
 	    	 if (!CompareOutput(vjOutputPtrC, refOutputPtrC))
 		     {
 	              INFO_PRINTF1(_L("The results are not equal"));
 	              
 	              SetTestStepResult(EFail);   
 	         }
 	     }
 	     else
 	     {
 	           IsItATossPacket(vjdecompRet, refdecompOutput);
 	     }
 	     
 	     
 	     CleanupStack::PopAndDestroy(vjPacketBuffer);
 	        
		 CleanupStack::PopAndDestroy(refPacketBuffer);
 	   
		 vjPacketBuffer = NULL;
		 refPacketBuffer = NULL;
	
} // VJDecompressTypeErrorTest