private async Task BasicProcessInfoTestCore(bool useAsync, bool suspend) { using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(targetFramework: "net5.0"), _output); if (suspend) { runner.SuspendDefaultDiagnosticPort(); } runner.Start(); try { DiagnosticsClientApiShim clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(runner.Pid), useAsync); // While suspended, the runtime will not provide entrypoint information. ProcessInfo processInfoBeforeResume = null; if (suspend) { processInfoBeforeResume = await clientShim.GetProcessInfo(); ValidateProcessInfo(runner.Pid, processInfoBeforeResume); Assert.True(string.IsNullOrEmpty(processInfoBeforeResume.ManagedEntrypointAssemblyName)); await clientShim.ResumeRuntime(); } // The entrypoint information is available some short time after the runtime // begins to execute. Retry getting process information until entrypoint is available. ProcessInfo processInfo = await GetProcessInfoWithEntrypointAsync(clientShim); ValidateProcessInfo(runner.Pid, processInfo); Assert.Equal("Tracee", processInfo.ManagedEntrypointAssemblyName); // Validate values before resume (except for entrypoint) are the same after resume. if (suspend) { Assert.Equal(processInfoBeforeResume.ProcessId, processInfo.ProcessId); Assert.Equal(processInfoBeforeResume.RuntimeInstanceCookie, processInfo.RuntimeInstanceCookie); Assert.Equal(processInfoBeforeResume.CommandLine, processInfo.CommandLine); Assert.Equal(processInfoBeforeResume.OperatingSystem, processInfo.OperatingSystem); Assert.Equal(processInfoBeforeResume.ProcessArchitecture, processInfo.ProcessArchitecture); Assert.Equal(processInfoBeforeResume.ClrProductVersionString, processInfo.ClrProductVersionString); } } finally { runner.PrintStatus(); } }
private async Task ResumeRuntime(IpcEndpointInfo info, bool useAsync) { var clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(info.Endpoint), useAsync); _outputHelper.WriteLine($"{info.RuntimeInstanceCookie}: Resuming runtime instance."); try { await clientShim.ResumeRuntime(DefaultPositiveVerificationTimeout); _outputHelper.WriteLine($"{info.RuntimeInstanceCookie}: Resumed successfully."); } catch (ServerErrorException ex) { // Runtime likely does not understand the ResumeRuntime command. _outputHelper.WriteLine($"{info.RuntimeInstanceCookie}: {ex.Message}"); } }
public static Task ResumeRuntime(this DiagnosticsClientApiShim shim) { return(shim.ResumeRuntime(DefaultPositiveVerificationTimeout)); }