Skip to content

Commit 3b51864

Browse files
committed
Add OS validation.
1 parent 383ab60 commit 3b51864

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,31 @@ public IEnumerable<ValidationError> Validate(ValidationParameters validationPara
109109
yield return new ValidationError(true, "Currently NativeAOT has no DisassemblyDiagnoser support", benchmark);
110110
}
111111

112-
if (RuntimeInformation.IsLinux() && ShouldUseClrMdDisassembler(benchmark))
112+
if (ShouldUseClrMdDisassembler(benchmark))
113113
{
114-
var runtime = benchmark.Job.ResolveValue(EnvironmentMode.RuntimeCharacteristic, EnvironmentResolver.Instance);
115-
116-
if (runtime.RuntimeMoniker < RuntimeMoniker.NetCoreApp30)
117-
{
118-
yield return new ValidationError(true, $"{nameof(DisassemblyDiagnoser)} supports only .NET Core 3.0+", benchmark);
119-
}
120-
121-
if (ptrace_scope.Value == "2")
114+
if (RuntimeInformation.IsLinux())
122115
{
123-
yield return new ValidationError(false, $"ptrace_scope is set to 2, {nameof(DisassemblyDiagnoser)} is going to work only if you run as sudo");
116+
var runtime = benchmark.Job.ResolveValue(EnvironmentMode.RuntimeCharacteristic, EnvironmentResolver.Instance);
117+
118+
if (runtime.RuntimeMoniker < RuntimeMoniker.NetCoreApp30)
119+
{
120+
yield return new ValidationError(true, $"{nameof(DisassemblyDiagnoser)} supports only .NET Core 3.0+", benchmark);
121+
}
122+
123+
if (ptrace_scope.Value == "2")
124+
{
125+
yield return new ValidationError(false, $"ptrace_scope is set to 2, {nameof(DisassemblyDiagnoser)} is going to work only if you run as sudo");
126+
}
127+
else if (ptrace_scope.Value == "3")
128+
{
129+
yield return new ValidationError(true, $"ptrace_scope is set to 3, {nameof(DisassemblyDiagnoser)} is not going to work");
130+
}
124131
}
125-
else if (ptrace_scope.Value == "3")
132+
// when we add macOS support, RuntimeInformation.IsMacOS() needs to be added here
133+
else if (!RuntimeInformation.IsWindows())
126134
{
127-
yield return new ValidationError(true, $"ptrace_scope is set to 3, {nameof(DisassemblyDiagnoser)} is not going to work");
135+
yield return new ValidationError(true, $"Only Windows and Linux are supported in DisassemblyDiagnoser without Mono. Current OS is {System.Runtime.InteropServices.RuntimeInformation.OSDescription}");
136+
yield break;
128137
}
129138
}
130139
}

0 commit comments

Comments
 (0)