Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux NativeAOT debug info regression test #81612

Merged
merged 13 commits into from
Feb 14, 2023
14 changes: 14 additions & 0 deletions src/tests/nativeaot/SmokeTests/DwarfDump/DwarfDump.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestKind>BuildAndRun</CLRTestKind>
<CLRTestPriority>0</CLRTestPriority>
<!-- Test checks symbols, so don't run in non-debug builds. -->
<CLRTestTargetUnsupported Condition="'$(Configuration)' != 'Debug' or '$(TargetOS)' != 'linux'">true</CLRTestTargetUnsupported>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
</Project>
75 changes: 75 additions & 0 deletions src/tests/nativeaot/SmokeTests/DwarfDump/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
agocke marked this conversation as resolved.
Show resolved Hide resolved
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

public class Program
{
public static int Main(string[] args)
{
var llvmDwarfDumpPath = Path.Combine(
Environment.GetEnvironmentVariable("CORE_ROOT"),
"SuperFileCheck",
"runtimes",
RuntimeInformation.RuntimeIdentifier,
"native",
"llvm-dwarfdump");

if (!File.Exists(llvmDwarfDumpPath))
{
// Linux-only test
Console.WriteLine("Could not find llvm-dwarfdump at path: " + llvmDwarfDumpPath);
return 1;
}

Console.WriteLine("Running llvm-dwarfdump");
var proc = Process.Start(llvmDwarfDumpPath, "--version");

if (proc is null)
{
Console.WriteLine("llvm-dwarfdump could not run");
return 2;
}

proc.WaitForExit();
if (proc.ExitCode != 0)
{
return 3;
}

proc = Process.Start(new ProcessStartInfo
{
FileName = llvmDwarfDumpPath,
Arguments = $"--verify {Environment.ProcessPath}",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
});

// Just count the number of warnings and errors. There are so many right now that it's not worth enumerating the list
const int MinWarnings = 18400;
const int MaxWarnings = 48600;
int count = 0;
string line;
while ((line = proc.StandardOutput.ReadLine()) != null)
{
if (line.Contains("warning:") || line.Contains("error:"))
{
count++;
}
}
proc.WaitForExit();
Console.WriteLine($"Found {count} warnings and errors");
if (count is not >= MinWarnings and <= MaxWarnings)
{
Console.WriteLine($"Found {count} warnings and errors, expected between {MinWarnings} and {MaxWarnings}");
Console.WriteLine("This is likely a result of debug info changes. To see the new output, run the following command:");
Console.WriteLine("\tllvm-dwarfdump --verify " + Environment.ProcessPath);
return 10;
}
return 100;
}
}