-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Enable IlasmRoundTrip tests for merged tests #93368
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
8dd8951
Initial work
TIHan d348160
Tweak
TIHan 41394cb
Tweak
TIHan d5afb0e
Do not generate _ilasmroundtrip.py for tests that have a generated ru…
TIHan c59ea7d
Reduce imports
TIHan a3a41cf
Force fail to see where CI fails
TIHan 20adfcd
Revert forcing failure. Run roundtrip on build.
TIHan b91c82d
Trying to fix script
TIHan fa91e26
Backslash tweak
TIHan a825fe8
Do not roundtrip the same assembly
TIHan ede1994
Fixing
TIHan 828c4b0
Remove import glob
TIHan 844eb49
Added is_managed_assembly
TIHan 265d870
remove print
TIHan cd497ac
Fixed paths
TIHan 969369b
Support bash. Ignore certain tests for arm. Fix poison test.
TIHan c1e0b1f
Update CLRTest.Jit.targets
TIHan f654a59
Feedback. Added AssemblyChecker.
TIHan 54d65a8
Merge branch 'ilasm-roundtrip-fix' of https://github.com/TIHan/runtim…
TIHan b06879a
Fix paths
TIHan 9f8d9e8
Update src/tests/Common/Directory.Build.targets
TIHan 9b7bf31
Feedback
TIHan 0b14d98
Feedback
TIHan 7aca653
Update AssemblyChecker.csproj
TIHan e9abeb4
Update Program.cs
TIHan 5f57ed6
Trying to fix calling python on helix.
TIHan ca91893
Remove old roundtrip script calls. Added --is-exe option for Assembly…
TIHan ba6fc6f
Tweak option:
TIHan d564396
Remove check
TIHan c9d1e49
Remove imports
TIHan 18914d8
Fix build
TIHan 1a6476a
Fix syntax errors. Fixed Popen arguments
TIHan 4e97e05
Fixed Popen arguments
TIHan b2c85b9
Fixing debug check
TIHan e25f1d4
Fixing tests
TIHan 2ed31da
Update ILVerificationTests.csproj
TIHan f9c41e9
Fixing tests
TIHan fe51ff1
Feedback
TIHan 703e89b
Feedback
TIHan 7b4796a
Update CLRTest.Jit.targets
TIHan dcff071
Added help usage flag for AssemblyChecker
TIHan 4a2442e
Feedback on assembly-checker
TIHan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AssemblyName>AssemblyChecker</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendTargetFrameworkToOutputPath Condition="'$(BuildingInsideVisualStudio)' == 'true'">true</AppendTargetFrameworkToOutputPath> | ||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<OutputPath>$(RuntimeBinDir)\AssemblyChecker</OutputPath> | ||
<RunAnalyzers>false</RunAnalyzers> | ||
</PropertyGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text; | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using System.Reflection.Metadata; | ||
using System.Reflection.PortableExecutable; | ||
|
||
namespace AssemblyChecker | ||
{ | ||
/// <summary> | ||
/// This is a simple console application that is designed to answer True or False | ||
/// questions about whether a given file is a managed assembly or not. | ||
/// You can also ask whether or not the assembly is debuggable. | ||
/// Return code of 0 indicates the file is a managed assembly. | ||
/// Return code of 1 indicates the file is not a managed assembly. No errors will be printed for this one. | ||
/// </summary> | ||
public class Program | ||
{ | ||
private const string HelpText = @" | ||
Usage: | ||
<filePath>: Check if the file-path is a managed assembly. | ||
--is-debug <filePath>: Check if the file-path is a managed assembly that is built with debuggability. | ||
--is-exe <filePath>: Check if the file-path is a managed assembly that is an executable. | ||
"; | ||
|
||
static bool IsAssembly(string path) | ||
{ | ||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
|
||
// Try to read CLI metadata from the PE file. | ||
using var peReader = new PEReader(fs); | ||
|
||
if (!peReader.HasMetadata) | ||
{ | ||
return false; // File does not have CLI metadata. | ||
} | ||
|
||
// Check that file has an assembly manifest. | ||
MetadataReader reader = peReader.GetMetadataReader(); | ||
return reader.IsAssembly; | ||
} | ||
|
||
static bool IsDebug(string path) | ||
{ | ||
return | ||
Assembly.LoadFrom(path) | ||
.GetCustomAttributes(typeof(DebuggableAttribute), false) | ||
.OfType<DebuggableAttribute>().Any(x => x.IsJITOptimizerDisabled); | ||
} | ||
|
||
static bool IsExe(string path) | ||
{ | ||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
|
||
// Try to read CLI metadata from the PE file. | ||
using var peReader = new PEReader(fs); | ||
|
||
if (!peReader.HasMetadata) | ||
{ | ||
return false; // File does not have CLI metadata. | ||
} | ||
|
||
return peReader.PEHeaders.IsExe; | ||
} | ||
|
||
static int Main(string[] args) | ||
{ | ||
if (args.Length == 0) | ||
{ | ||
Console.WriteLine(HelpText); | ||
Console.Error.WriteLine("\nExpected assembly file-path."); | ||
return 2; | ||
} | ||
|
||
// Help | ||
if (args.Contains("-h")) | ||
{ | ||
Console.WriteLine(HelpText); | ||
return 0; | ||
} | ||
|
||
if (args.Length == 1) | ||
{ | ||
return IsAssembly(args[0]) ? 0 : 1; | ||
} | ||
|
||
if (args.Length == 2) | ||
{ | ||
switch (args[0]) | ||
{ | ||
case "--is-debug": | ||
{ | ||
return IsDebug(args[1]) ? 0 : 1; | ||
} | ||
|
||
case "--is-exe": | ||
{ | ||
return IsExe(args[1]) ? 0 : 1; | ||
} | ||
|
||
default: | ||
{ | ||
Console.WriteLine(HelpText); | ||
Console.Error.WriteLine("\nInvalid option."); | ||
return 2; | ||
} | ||
} | ||
} | ||
|
||
Console.WriteLine(HelpText); | ||
Console.Error.WriteLine("\nToo many arguments."); | ||
return 2; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.