コード例 #1
0
ファイル: SOS.cs プロジェクト: vitek-karas/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)
        {
            // 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);
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #2
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);
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
ファイル: SOS.cs プロジェクト: tmds/diagnostics
 public async Task GCTests(TestConfiguration config)
 {
     // Live only
     SkipIfArm(config);
     if (SOSRunner.IsAlpine())
     {
         throw new SkipTestException("lldb tests not supported on Alpine");
     }
     using (SOSRunner runner = await SOSRunner.StartDebugger(config, Output, testName: "SOS.GCTests", debuggeeName: "GCWhere"))
     {
         await runner.RunScript("GCTests.script");
     }
 }
コード例 #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
ファイル: 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);
                    }
                }
            }
        }
    }
コード例 #6
0
ファイル: SOS.cs プロジェクト: tmds/diagnostics
    private async Task RunTest(TestConfiguration config, string testName, string debuggeeName, string scriptName, string debuggeeArguments = null, bool useCreateDump = true)
    {
        SkipIfArm(config);

        if (!SOSRunner.IsAlpine())
        {
            // Live
            using (SOSRunner runner = await SOSRunner.StartDebugger(config, Output, testName, debuggeeName, debuggeeArguments))
            {
                await runner.RunScript(scriptName);
            }
        }

        // Generate a crash dump.
        if (IsCreateDumpConfig(config))
        {
            if (!useCreateDump && SOSRunner.IsAlpine())
            {
                throw new SkipTestException("lldb tests not supported on Alpine");
            }
            await SOSRunner.CreateDump(config, Output, testName, debuggeeName, debuggeeArguments, useCreateDump);
        }

        // Test against a crash dump.
        if (IsOpenDumpConfig(config))
        {
            if (!SOSRunner.IsAlpine())
            {
                // With cdb (Windows) or lldb (Linux or OSX)
                using (SOSRunner runner = await SOSRunner.StartDebugger(config, Output, testName, debuggeeName, debuggeeArguments, SOSRunner.Options.LoadDump))
                {
                    await runner.RunScript(scriptName);
                }
            }

            // With the dotnet-dump analyze tool
            if (config.DotNetDumpPath() != null)
            {
                using (SOSRunner runner = await SOSRunner.StartDebugger(config, Output, testName, debuggeeName, debuggeeArguments, SOSRunner.Options.LoadDumpWithDotNetDump))
                {
                    await runner.RunScript(scriptName);
                }
            }
        }
    }
コード例 #7
0
    public async Task LLDBPluginTests(TestConfiguration config)
    {
        if (OS.Kind == OSKind.Windows || config.IsDesktop || config.RuntimeFrameworkVersionMajor == 1 || SOSRunner.IsAlpine())
        {
            throw new SkipTestException("lldb plugin tests not supported on Windows, Alpine Linux or .NET Core 1.1");
        }
        string testName = "SOS." + nameof(LLDBPluginTests);

        TestRunner.OutputHelper outputHelper = null;
        try
        {
            // Setup the logging from the options in the config file
            outputHelper = TestRunner.ConfigureLogging(config, Output, testName);

            outputHelper.WriteLine("Starting {0}", testName);
            outputHelper.WriteLine("{");

            string program = "/usr/bin/python";
            if (!File.Exists(program))
            {
                throw new ArgumentException($"{program} does not exists");
            }
            var    arguments   = new StringBuilder();
            string repoRootDir = TestConfiguration.MakeCanonicalPath(config.AllSettings["RepoRootDir"]);

            // Get test python script path
            string scriptDir = Path.Combine(repoRootDir, "src", "SOS", "lldbplugin.tests");
            arguments.Append(Path.Combine(scriptDir, "test_libsosplugin.py"));
            arguments.Append(" ");

            // Get lldb path
            arguments.AppendFormat("--lldb {0} ", Environment.GetEnvironmentVariable("LLDB_PATH") ?? throw new ArgumentException("LLDB_PATH environment variable not set"));

            // Add dotnet host program and arguments
            arguments.Append("--host \"");
            arguments.Append(config.HostExe);
            arguments.Append(" ");
            if (!string.IsNullOrWhiteSpace(config.HostArgs))
            {
                arguments.Append(config.HostArgs);
                arguments.Append(" ");
            }
            arguments.Append("\" ");

            // Add lldb plugin path
            arguments.AppendFormat("--plugin {0} ", config.SOSPath() ?? throw new ArgumentException("SOSPath config not set"));

            // Add log directory
            string logFileDir = Path.Combine(config.LogDirPath, config.RuntimeFrameworkVersion);
            Directory.CreateDirectory(logFileDir);
            arguments.AppendFormat("--logfiledir {0} ", logFileDir);

            // Add test debuggee assembly
            string testDebuggee = Path.Combine(repoRootDir, "artifacts", "bin", "TestDebuggee", config.TargetConfiguration, config.BuildProjectFramework, "TestDebuggee.dll");
            arguments.AppendFormat("--assembly {0}", testDebuggee);

            // Create the python script process runner
            ProcessRunner processRunner = new ProcessRunner(program, arguments.ToString()).
                                          WithLog(new TestRunner.TestLogger(outputHelper.IndentedOutput)).
                                          WithTimeout(TimeSpan.FromMinutes(10)).
                                          WithExpectedExitCode(0).
                                          WithWorkingDirectory(scriptDir).
                                          // Turn on stress logging so the dumplog and histinit commands pass
                                          WithEnvironmentVariable("COMPlus_LogFacility", "0xffffffbf").
                                          WithEnvironmentVariable("COMPlus_LogLevel", "6").
                                          WithEnvironmentVariable("COMPlus_StressLog", "1").
                                          WithEnvironmentVariable("COMPlus_StressLogSize", "65536");

            // Start the process runner
            processRunner.Start();

            // Wait for the debuggee to finish
            await processRunner.WaitForExit();
        }
        catch (Exception ex)
        {
            // Log the exception
            outputHelper?.WriteLine(ex.ToString());
            throw;
        }
        finally
        {
            outputHelper?.WriteLine("}");
            outputHelper?.Dispose();
        }
    }