diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index 49bd585709..434c9c1f8d 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs @@ -13,6 +13,8 @@ using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Portability; using BenchmarkDotNet.Tests.Loggers; +using BenchmarkDotNet.Tests.XUnit; +using BenchmarkDotNet.Toolchains.InProcess.Emit; using Xunit; using Xunit.Abstractions; @@ -105,6 +107,33 @@ public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, Runtime run AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Recursive)}()"); } + // For some reason the GitHub runner with Core cannot fully disassemble, so we skip it. + [FactEnvSpecific("InProcess disassembly only supported on Windows x86/64.", EnvRequirement.WindowsOnly, EnvRequirement.X86X64Only, EnvRequirement.FullFrameworkOnly)] + [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] + public void CanDisassembleAllMethodCallsInProcess() + { + var disassemblyDiagnoser = new DisassemblyDiagnoser( + new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3)); + + var config = ManualConfig.CreateEmpty() + .AddJob(Job.Dry + .WithStrategy(RunStrategy.ColdStart) + .WithToolchain(InProcessEmitToolchain.Instance) + ) + .AddLogger(DefaultConfig.Instance.GetLoggers().ToArray()) + .AddColumnProvider(DefaultColumnProviders.Instance) + .AddDiagnoser(disassemblyDiagnoser) + .AddLogger(new OutputLogger(Output)); + + CanExecute(config); + + AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Benchmark)}(Int32)"); + AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Benchmark)}(Boolean)"); + AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Static)}()"); + AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Instance)}()"); + AssertDisassembled(disassemblyDiagnoser, $"{nameof(WithCalls.Recursive)}()"); + } + [Theory] [MemberData(nameof(GetAllJits))] [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] diff --git a/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirement.cs b/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirement.cs index cb2b1a3878..918ff438e0 100644 --- a/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirement.cs +++ b/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirement.cs @@ -8,5 +8,6 @@ public enum EnvRequirement FullFrameworkOnly, NonFullFramework, DotNetCoreOnly, - DotNetCore30Only + DotNetCore30Only, + X86X64Only } \ No newline at end of file diff --git a/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirementChecker.cs b/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirementChecker.cs index cbe4ac930e..e5f7822556 100644 --- a/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirementChecker.cs +++ b/tests/BenchmarkDotNet.Tests/XUnit/EnvRequirementChecker.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Runtime.InteropServices; +using BenchmarkDotNet.Environments; using BenchmarkDotNet.Jobs; using JetBrains.Annotations; using BdnRuntimeInformation = BenchmarkDotNet.Portability.RuntimeInformation; @@ -22,6 +23,7 @@ public static class EnvRequirementChecker EnvRequirement.NonFullFramework => !BdnRuntimeInformation.IsFullFramework ? null : "Non-Full .NET Framework test", EnvRequirement.DotNetCoreOnly => BdnRuntimeInformation.IsNetCore ? null : ".NET/.NET Core-only test", EnvRequirement.DotNetCore30Only => IsRuntime(RuntimeMoniker.NetCoreApp30) ? null : ".NET Core 3.0-only test", + EnvRequirement.X86X64Only => BdnRuntimeInformation.GetCurrentPlatform() is Platform.X64 or Platform.X86 ? null : "x86- or x64-only test", _ => throw new ArgumentOutOfRangeException(nameof(requirement), requirement, "Unknown value") };