예제 #1
0
    private async Task RunTest(string scriptName, SOSRunner.TestInformation information)
    {
        information.OutputHelper = Output;

        if (information.TestLive)
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.Live))
            {
                await runner.RunScript(scriptName);
            }
        }

        if (information.TestDump)
        {
            string dumpName = null;

            // Generate a crash dump.
            if (information.DebuggeeDumpOutputRootDir != null)
            {
                dumpName = await SOSRunner.CreateDump(information);
            }

            // Test against a crash dump.
            if (information.DebuggeeDumpInputRootDir != null)
            {
                // With cdb (Windows) or lldb (Linux)
                using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump))
                {
                    await runner.RunScript(scriptName);
                }

                // Using the dotnet-dump analyze tool if the path exists in the config file.
                // TODO: dotnet-dump currently doesn't support macho core dumps that the MacOS createdump generates
                if (information.TestConfiguration.DotNetDumpPath() != null && OS.Kind != OSKind.OSX)
                {
                    // Don't test dotnet-dump on triage dumps when running on desktop CLR.
                    if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)
                    {
                        using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
                        {
                            await runner.RunScript(scriptName);
                        }
                    }
                }
            }

            // Test the crash report json file
            if (dumpName != null && information.TestCrashReport)
            {
                TestCrashReport(dumpName, information);
            }
        }
    }
예제 #2
0
파일: SOS.cs 프로젝트: Maoni0/diagnostics
    private void TestCrashReport(string dumpName, SOSRunner.TestInformation information)
    {
        string crashReportPath = dumpName + ".crashreport.json";

        TestRunner.OutputHelper outputHelper = TestRunner.ConfigureLogging(information.TestConfiguration, information.OutputHelper, information.TestName + ".CrashReportTest");
        try
        {
            outputHelper.WriteLine("CrashReportTest for {0}", crashReportPath);
            outputHelper.WriteLine("{");

            AssertX.FileExists("CrashReport", crashReportPath, outputHelper.IndentedOutput);

            dynamic crashReport = JsonConvert.DeserializeObject(File.ReadAllText(crashReportPath));
            Assert.NotNull(crashReport);

            dynamic payload = crashReport.payload;
            Assert.NotNull(payload);
            Version protocol_version = Version.Parse((string)payload.protocol_version);
            Assert.True(protocol_version >= new Version("1.0.0"));
            outputHelper.IndentedOutput.WriteLine($"protocol_version {protocol_version}");

            string process_name = (string)payload.process_name;
            Assert.NotNull(process_name);
            outputHelper.IndentedOutput.WriteLine($"process_name {process_name}");

            Assert.NotNull(payload.threads);
            IEnumerable <dynamic> threads = payload.threads;
            Assert.True(threads.Any());
            outputHelper.IndentedOutput.WriteLine($"threads # {threads.Count()}");

            if (OS.Kind == OSKind.OSX)
            {
                dynamic parameters = crashReport.parameters;
                Assert.NotNull(parameters);
                Assert.NotNull(parameters.ExceptionType);
                Assert.NotNull(parameters.OSVersion);
                Assert.Equal("apple", (string)parameters.SystemManufacturer);
            }
        }
        catch (Exception ex)
        {
            // Log the exception
            outputHelper.IndentedOutput.WriteLine(ex.ToString());
        }
        finally
        {
            outputHelper.WriteLine("}");
            outputHelper.Dispose();
        }
    }
예제 #3
0
    private async Task RunTest(string scriptName, bool testLive = true, bool testDump = true, SOSRunner.TestInformation information = null)
    {
        information.OutputHelper = Output;

        if (testLive && !SOSRunner.IsAlpine())
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.Live))
            {
                await runner.RunScript(scriptName);
            }
        }

        if (testDump)
        {
            // Create and test dumps on OSX only if the runtime is 5.0 or greater
            if (OS.Kind != OSKind.OSX || information.TestConfiguration.RuntimeFrameworkVersionMajor >= 5)
            {
                // Generate a crash dump.
                if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null)
                {
                    if (information.DumpGenerator == SOSRunner.DumpGenerator.NativeDebugger && SOSRunner.IsAlpine())
                    {
                        throw new SkipTestException("lldb tests not supported on Alpine");
                    }
                    await SOSRunner.CreateDump(information);
                }

                // Test against a crash dump.
                if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null)
                {
                    if (!SOSRunner.IsAlpine() && OS.Kind != OSKind.OSX)
                    {
                        // With cdb (Windows) or lldb (Linux)
                        using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump))
                        {
                            await runner.RunScript(scriptName);
                        }
                    }

                    // Using the dotnet-dump analyze tool if the path exists in the config file.
                    if (information.TestConfiguration.DotNetDumpPath() != null)
                    {
                        // Don't test dotnet-dump on triage dumps when running on desktop CLR.
                        if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)
                        {
                            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
                            {
                                await runner.RunScript(scriptName);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #4
0
    private async Task RunTest(string scriptName, bool testLive = true, bool testDump = true, SOSRunner.TestInformation information = null)
    {
        information.OutputHelper = Output;

        // TODO: enable either when bpmd is fixed on Alpine or the bpmd tests are ifdef'ed out of the scripts for Alpine
        if (testLive)
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.Live))
            {
                await runner.RunScript(scriptName);
            }
        }

        if (testDump)
        {
            // Create and test dumps on OSX or Alpine only if the runtime is 6.0 or greater
            if (!(OS.Kind == OSKind.OSX || SOSRunner.IsAlpine()) || information.TestConfiguration.RuntimeFrameworkVersionMajor > 5)
            {
                // Generate a crash dump.
                if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null)
                {
                    await SOSRunner.CreateDump(information);
                }

                // Test against a crash dump.
                if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null)
                {
                    // With cdb (Windows) or lldb (Linux)
                    using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump))
                    {
                        await runner.RunScript(scriptName);
                    }

                    // Using the dotnet-dump analyze tool if the path exists in the config file.
                    // TODO: dotnet-dump currently doesn't support macho core dumps that the MacOS createdump generates
                    if (information.TestConfiguration.DotNetDumpPath() != null && OS.Kind != OSKind.OSX)
                    {
                        // Don't test dotnet-dump on triage dumps when running on desktop CLR.
                        if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)
                        {
                            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
                            {
                                await runner.RunScript(scriptName);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #5
0
    private async Task RunTest(string scriptName, bool testLive = true, bool testDump = true, SOSRunner.TestInformation information = null)
    {
        information.OutputHelper = Output;

        if (testLive && !SOSRunner.IsAlpine())
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.Live))
            {
                await runner.RunScript(scriptName);
            }
        }

        if (testDump)
        {
            // Create and test dumps on OSX only if the runtime is 6.0 or greater
            // TODO: reenable for 5.0 when the MacOS createdump fixes make it into a service release (https://github.com/dotnet/diagnostics/issues/1749)
            if (OS.Kind != OSKind.OSX || information.TestConfiguration.RuntimeFrameworkVersionMajor > 5)
            {
                // Generate a crash dump.
                if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null)
                {
                    if (information.DumpGenerator == SOSRunner.DumpGenerator.NativeDebugger && SOSRunner.IsAlpine())
                    {
                        throw new SkipTestException("lldb tests not supported on Alpine");
                    }
                    await SOSRunner.CreateDump(information);
                }

                // Test against a crash dump.
                if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null)
                {
                    if (!SOSRunner.IsAlpine())
                    {
                        // With cdb (Windows) or lldb (Linux)
                        using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump))
                        {
                            await runner.RunScript(scriptName);
                        }
                    }

                    // Using the dotnet-dump analyze tool if the path exists in the config file.
                    // TODO: dotnet-dump currently doesn't support macho core dumps that the MacOS createdump generates
                    if (information.TestConfiguration.DotNetDumpPath() != null && OS.Kind != OSKind.OSX)
                    {
                        // Don't test dotnet-dump on triage dumps when running on desktop CLR.
                        if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)
                        {
                            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
                            {
                                await runner.RunScript(scriptName);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #6
0
파일: SOS.cs 프로젝트: ziyasal/diagnostics
    private async Task RunTest(string scriptName, bool testLive = true, bool testDump = true, SOSRunner.TestInformation information = null)
    {
        information.OutputHelper = Output;

        if (testLive && !SOSRunner.IsAlpine())
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.Live))
            {
                await runner.RunScript(scriptName);
            }
        }

        if (testDump)
        {
            // Generate a crash dump.
            if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null)
            {
                if (information.DumpGenerator == SOSRunner.DumpGenerator.NativeDebugger && SOSRunner.IsAlpine())
                {
                    throw new SkipTestException("lldb tests not supported on Alpine");
                }
                await SOSRunner.CreateDump(information);
            }

            // Test against a crash dump.
            if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null)
            {
                if (!SOSRunner.IsAlpine())
                {
                    // With cdb (Windows) or lldb (Linux or OSX)
                    using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump))
                    {
                        await runner.RunScript(scriptName);
                    }
                }

                // With the dotnet-dump analyze tool
                if (information.TestConfiguration.DotNetDumpPath() != null)
                {
                    using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
                    {
                        await runner.RunScript(scriptName);
                    }
                }
            }
        }
    }