protected string RunExecutableAndGetOutput(bool runTestsViewOut, string pspAutoTestsFolder, string fileName, out string capturedOutput, string fileNameBase) { var outputString = ""; IHleIoDriver hostDriver = null; //Console.WriteLine(FileNameBase); InjectContext injectContext = null; { //var Capture = false; var capture = !runTestsViewOut; capturedOutput = ConsoleUtils.CaptureOutput(() => { injectContext = PspInjectContext.CreateInjectContext(StoredConfig, test: true); injectContext.SetInstanceType <HleOutputHandler, HleOutputHandlerMock>(); var cpuConfig = injectContext.GetInstance <CpuConfig>(); var hleConfig = injectContext.GetInstance <HleConfig>(); cpuConfig.DebugSyscalls = false; cpuConfig.ShowInstructionStats = false; hleConfig.TraceLastSyscalls = false; hleConfig.DebugSyscalls = false; //Console.Error.WriteLine("[1]"); var start = DateTime.UtcNow; injectContext.GetInstance <HleModuleManager>(); var end = DateTime.UtcNow; Console.WriteLine(end - start); //Console.Error.WriteLine("[a]"); // GPU -> NULL //PspEmulatorContext.SetInstanceType<GpuImpl>(typeof(GpuImplOpenglEs)); injectContext.SetInstanceType <GpuImpl>(typeof(GpuImplNull)); var gpuImpl = injectContext.GetInstance <GpuImpl>(); //GpuImpl.InitSynchronizedOnce(); //Console.Error.WriteLine("[b]"); var pspRunner = injectContext.GetInstance <PspRunner>(); pspRunner.StartSynchronized(); //Console.Error.WriteLine("[c]"); { try { //PspRunner.CpuComponentThread.SetIso(PspAutoTestsFolder + "/../input/test.cso"); pspRunner.CpuComponentThread.SetIso(pspAutoTestsFolder + "/../input/cube.cso"); //Console.Error.WriteLine("[2]"); var hleIoManager = injectContext.GetInstance <HleIoManager>(); hostDriver = hleIoManager.GetDriver("host:"); try { hostDriver.IoRemove(null, "/__testoutput.txt"); } catch (Exception e) { Console.WriteLine(e); } try { hostDriver.IoRemove(null, "/__testerror.txt"); } catch (Exception e) { Console.WriteLine(e); } injectContext.GetInstance <PspHleRunningConfig>().FileNameBase = fileNameBase; pspRunner.CpuComponentThread._LoadFile(fileName); //Console.Error.WriteLine("[3]"); if (!pspRunner.CpuComponentThread.StoppedEndedEvent.WaitOne(_timeoutTime)) { ConsoleUtils.SaveRestoreConsoleColor(ConsoleColor.Red, () => { Console.Error.WriteLine("Timeout!"); }); } } catch (Exception e) { Console.Error.WriteLine(e); } } pspRunner.StopSynchronized(); GC.Collect(); using var testOutput = hostDriver.OpenRead("/__testoutput.txt"); outputString = testOutput.ReadAllContentsAsString(); }, capture: capture ); //var HleOutputHandlerMock = (HleOutputHandlerMock)PspEmulatorContext.GetInstance<HleOutputHandler>(); //OutputString = HleOutputHandlerMock.OutputString; } injectContext.Dispose(); return(outputString); }