Ejemplo n.º 1
0
        public void BasicWriteDumpTest()
        {
            var        dumpPath = "./myDump.dmp";
            TestRunner runner   = new TestRunner(CommonHelper.GetTraceePath(), output);

            runner.Start(3000);
            DiagnosticsClient client = new DiagnosticsClient(runner.Pid);

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.Normal, dumpPath));
            }
            else
            {
                output.WriteLine($"Requesting dump at {DateTime.Now.ToString()}");
                client.WriteDump(DumpType.Normal, dumpPath);
                Assert.True(File.Exists(dumpPath));
                File.Delete(dumpPath);
            }
            runner.Stop();
        }
Ejemplo n.º 2
0
        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"));
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        public void BasicWriteDumpTest()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                var dumpPath = "./myDump.dmp";
                using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output);
                runner.Start(timeoutInMSPipeCreation: 3000);
                DiagnosticsClient client = new DiagnosticsClient(runner.Pid);

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.Version.ToString().StartsWith("3"))
                {
                    Assert.Throws <UnsupportedCommandException>(() => client.WriteDump(DumpType.Normal, dumpPath));
                }
                else
                {
                    output.WriteLine($"Requesting dump at {DateTime.Now.ToString()}");
                    client.WriteDump(DumpType.Normal, dumpPath);
                    Assert.True(File.Exists(dumpPath));
                    File.Delete(dumpPath);
                }

                runner.Stop();
            }
        }
Ejemplo n.º 5
0
        public void WriteAllDumpTypesTest()
        {
            var normalDumpPath = "./myDump-normal.dmp";
            var heapDumpPath   = "./myDump-heap.dmp";
            var triageDumpPath = "./myDump-triage.dmp";
            var fullDumpPath   = "./myDump-full.dmp";

            using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output);
            runner.Start(3000);
            DiagnosticsClient client = new DiagnosticsClient(runner.Pid);

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.Normal, normalDumpPath));
                Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.WithHeap, heapDumpPath));
                Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.Triage, triageDumpPath));
                Assert.Throws <PlatformNotSupportedException>(() => client.WriteDump(DumpType.Full, fullDumpPath));
            }
            else
            {
                // Write each type of dump
                output.WriteLine($"Requesting dump at {DateTime.Now.ToString()}");
                client.WriteDump(DumpType.Normal, normalDumpPath);
                client.WriteDump(DumpType.WithHeap, heapDumpPath);
                client.WriteDump(DumpType.Triage, triageDumpPath);
                client.WriteDump(DumpType.Full, fullDumpPath);

                // Check they were all created
                Assert.True(File.Exists(normalDumpPath));
                Assert.True(File.Exists(heapDumpPath));
                Assert.True(File.Exists(triageDumpPath));
                Assert.True(File.Exists(fullDumpPath));

                // Remove them
                File.Delete(normalDumpPath);
                File.Delete(heapDumpPath);
                File.Delete(triageDumpPath);
                File.Delete(fullDumpPath);
            }
            runner.Stop();
        }