public void MultiplePublishedProcessTest() { TestRunner[] runner = new TestRunner[3]; int[] pids = new int[3]; for (var i = 0; i < 3; i++) { runner[i] = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); runner[i].Start(); pids[i] = runner[i].Pid; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Thread.Sleep(5000); } List <int> publishedProcesses = new List <int>(DiagnosticsClient.GetPublishedProcesses()); foreach (int p in publishedProcesses) { output.WriteLine($"[{DateTime.Now.ToString()}] Saw published process {p}"); } for (var i = 0; i < 3; i++) { Assert.Contains(publishedProcesses, p => p == pids[i]); } for (var i = 0; i < 3; i++) { runner[i].Stop(); } }
public void EventPipeSessionUnavailableTest() { List <int> pids = new List <int>(DiagnosticsClient.GetPublishedProcesses()); int arbitraryPid = 1; DiagnosticsClient client = new DiagnosticsClient(arbitraryPid); Assert.Throws <ServerNotAvailableException>(() => client.StartEventPipeSession(new List <EventPipeProvider>() { new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational) })); }
/// <summary> /// Tries to start an EventPipe session on a non-existent process /// </summary> private async Task EventPipeSessionUnavailableTestCore(bool useAsync) { List <int> pids = new List <int>(DiagnosticsClient.GetPublishedProcesses()); int arbitraryPid = 1; DiagnosticsClientApiShim clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(arbitraryPid), useAsync); await Assert.ThrowsAsync <ServerNotAvailableException>(() => clientShim.StartEventPipeSession(new List <EventPipeProvider>() { new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational) })); }
public void PublishedProcessTest1() { TestRunner runner = new TestRunner(CommonHelper.GetTraceePath(), output); runner.Start(3000); List <int> publishedProcesses = new List <int>(DiagnosticsClient.GetPublishedProcesses()); foreach (int p in publishedProcesses) { output.WriteLine($"[{DateTime.Now.ToString()}] Saw published process {p}"); } Assert.Contains(publishedProcesses, p => p == runner.Pid); runner.Stop(); }
public void WriteDumpFailTest() { List <int> pids = new List <int>(DiagnosticsClient.GetPublishedProcesses()); int arbitraryPid = 1; string dumpPath = "./myDump.dmp"; while (pids.Contains(arbitraryPid)) { arbitraryPid += 1; } var client = new DiagnosticsClient(arbitraryPid); Assert.Throws <ServerNotAvailableException>(() => client.WriteDump(DumpType.Normal, dumpPath)); }
public void PublishedProcessTest1() { using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); runner.Start(timeoutInMSPipeCreation: 3000); // On Windows, runner.Start will not wait for named pipe creation since for other tests, NamedPipeClientStream will // just wait until the named pipe is created. // For these tests, we need to sleep an arbitrary time before pipe is created. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Thread.Sleep(5000); } List <int> publishedProcesses = new List <int>(DiagnosticsClient.GetPublishedProcesses()); foreach (int p in publishedProcesses) { output.WriteLine($"[{DateTime.Now.ToString()}] Saw published process {p}"); } Assert.Contains(publishedProcesses, p => p == runner.Pid); runner.Stop(); }
public void WriteDumpFailTest() { List <int> pids = new List <int>(DiagnosticsClient.GetPublishedProcesses()); int arbitraryPid = 1; string dumpPath = "./myDump.dmp"; while (pids.Contains(arbitraryPid)) { arbitraryPid += 1; } var client = new DiagnosticsClient(arbitraryPid); if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.Normal, dumpPath)); } else { Assert.Throws <ServerNotAvailableException>(() => client.WriteDump(DumpType.Normal, "./myDump.dmp")); } }