-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
Program.cs
105 lines (93 loc) · 3.23 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Xunit;
public class Program
{
[Fact]
public static int TestEntryPoint()
{
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
#if DEBUG
const int MinWarnings = 2000;
const int MaxWarnings = 4000;
#else
const int MinWarnings = 3000;
const int MaxWarnings = 5000;
#endif
int count = 0;
string line;
while ((line = proc.StandardOutput.ReadLine()) != null)
{
if (line.Contains("warning:") || line.Contains("error:"))
{
count++;
}
}
if (count == 0)
{
// something is off, lets check the StandardError stream
int errorCount = 0;
string[] firstFiveErrors = new string[5];
while ((line = proc.StandardError.ReadLine()) != null)
{
if (line.Contains("error:"))
{
if (errorCount < 5) firstFiveErrors[errorCount] = line;
errorCount++;
}
}
if (errorCount > 0)
{
Console.Error.WriteLine($"llvm-dwarfdump failed. First five errors:{Environment.NewLine}{string.Join(Environment.NewLine, firstFiveErrors)}");
return 10;
}
}
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;
}
}