Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 63 additions & 41 deletions src/tests/Common/CLRTest.Jit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ def is_managed_exe_assembly(file):
print("")
print("ILASM RoundTrips")

if os.environ.get("IlasmRoundTripUseManagedIlasm") == "1":
ilasm_path = os.path.join(os.environ["CORE_ROOT"], "managed-ilasm", "ilasm")
else:
ilasm_path = os.path.join(os.environ["CORE_ROOT"], "ilasm")

if not os.path.exists("IL-RT"):
os.mkdir("IL-RT")

Expand Down Expand Up @@ -367,7 +372,11 @@ for inputAssemblyName in glob.glob("*.dll"):
proc.kill()
sys.exit(1)

ilasm_args = f'{os.environ["CORE_ROOT"]}/ilasm -output={inputAssemblyName} {ilasmSwitches} {disassemblyName}'
if proc.returncode != 0:
print(f"ILDASM failed with exit code {proc.returncode}")
sys.exit(1)

ilasm_args = f'{ilasm_path} -output={inputAssemblyName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)

Expand All @@ -377,63 +386,76 @@ for inputAssemblyName in glob.glob("*.dll"):
proc.kill()
sys.exit(1)

test_det = proc.returncode == 0
if proc.returncode != 0:
print(f"ILASM failed with exit code {proc.returncode}")
sys.exit(1)

# Test determinism
if test_det:

hash = hash_file(inputAssemblyName)
hash = hash_file(inputAssemblyName)

ilasm_args = f'{os.environ["CORE_ROOT"]}/ilasm -output={inputAssemblyName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)
ilasm_args = f'{ilasm_path} -output={inputAssemblyName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)

try:
proc.communicate()
except:
proc.kill()
sys.exit(1)
try:
proc.communicate()
except:
proc.kill()
sys.exit(1)

if hash != hash_file(inputAssemblyName):
print("ILASM determinism failed")
if proc.returncode != 0:
print(f"ILASM failed with exit code {proc.returncode}")
sys.exit(1)
else:
print("ILASM determinism succeeded")

# Test PDB determinism
if hash != hash_file(inputAssemblyName):
print("ILASM determinism failed")
sys.exit(1)
else:
print("ILASM determinism succeeded")

if not is_managed_debug_assembly(inputAssemblyName):
ilasmSwitches = ilasmSwitches + " -DEBUG"
# Test PDB determinism

pdbName = inputAssemblyName.replace('.dll', '.pdb')
if not is_managed_debug_assembly(inputAssemblyName):
ilasmSwitches = ilasmSwitches + " -DEBUG"

pdbName = inputAssemblyName.replace('.dll', '.pdb')

ilasm_args = f'{ilasm_path} -output={pdbName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)

ilasm_args = f'{os.environ["CORE_ROOT"]}/ilasm -output={pdbName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)
try:
proc.communicate()
except:
proc.kill()
sys.exit(1)

try:
proc.communicate()
except:
proc.kill()
sys.exit(1)
if proc.returncode != 0:
print(f"ILASM failed with exit code {proc.returncode}")
sys.exit(1)

hash = hash_file(pdbName)
hash = hash_file(pdbName)

ilasm_args = f'{os.environ["CORE_ROOT"]}/ilasm -output={pdbName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)
ilasm_args = f'{ilasm_path} -output={pdbName} {ilasmSwitches} {disassemblyName}'
print(ilasm_args)
proc = subprocess.Popen(ilasm_args, shell=True)

try:
proc.communicate()
except:
proc.kill()
sys.exit(1)
try:
proc.communicate()
except:
proc.kill()
sys.exit(1)

if hash != hash_file(pdbName):
print("ILASM PDB determinism failed")
if proc.returncode != 0:
print(f"ILASM failed with exit code {proc.returncode}")
sys.exit(1)
else:
print("ILASM PDB determinism succeeded")

if hash != hash_file(pdbName):
print("ILASM PDB determinism failed")
sys.exit(1)
else:
print("ILASM PDB determinism succeeded")

print("")

Expand Down
8 changes: 6 additions & 2 deletions src/tests/Common/testenvironment.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@


<!-- DOTNET_* variables that can be specified for a test scenario -->
<!-- There is a non-DOTNET variable here: RunningIlasmRoundTrip. When set to 1, this triggers CoreCLR round-trip testing.
The value is read in the test wrapper scripts. When set in a __TestEnv script, it is set before it is read.
<!-- There are non-DOTNET variables here: RunningIlasmRoundTrip and IlasmRoundTripUseManagedIlasm.
RunningIlasmRoundTrip, when set to 1, triggers CoreCLR round-trip testing.
IlasmRoundTripUseManagedIlasm, when set to 1, uses the managed ilasm for round-trip testing.
Both values are read in the test wrapper scripts. When set in a __TestEnv script, they are set before they are read.
The DOTNET_ processing handling below allows for variables not prefixed by 'DOTNET_'.
-->
<PropertyGroup>
Expand Down Expand Up @@ -66,6 +68,7 @@
DOTNET_JitForceControlFlowGuard;
DOTNET_JitCFGUseDispatcher;
RunningIlasmRoundTrip;
IlasmRoundTripUseManagedIlasm;
DOTNET_JitSynthesizeCounts;
Comment thread
jkoritzinsky marked this conversation as resolved.
DOTNET_JitCheckSynthesizedCounts;
DOTNET_JitRLCSEGreedy;
Expand Down Expand Up @@ -191,6 +194,7 @@
<TestEnvironment Include="jitcfg_dispatcher_never" JitForceControlFlowGuard="1" JitCFGUseDispatcher="0" />
<TestEnvironment Include="jitcfg_gcstress0xc" JitForceControlFlowGuard="1" GCStress="0xC" />
<TestEnvironment Include="ilasmroundtrip" RunningIlasmRoundTrip="1" />
<TestEnvironment Include="managedilasmroundtrip" RunningIlasmRoundTrip="1" IlasmRoundTripUseManagedIlasm="1" />
<TestEnvironment Include="clrinterpreter" TieredCompilation="1" />
<TestEnvironment Include="defaultpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" />
<TestEnvironment Include="fullpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitProfileCasts="1"/>
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Interop/IJW/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
<!-- C++/CLI not supported with NativeAOT -->
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- IJW assemblies contain native code that cannot be round-tripped through ilasm -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions src/tests/JIT/jit64/opt/cse/hugeexpr1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<!-- Takes long time to compile and not interesting from AOT perspective -->
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- This test generates IL that is too large for ilasm to round-trip -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
</PropertyGroup>
<PropertyGroup>
<DebugType>Full</DebugType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- RequiresProcessIsolation due to IlasmRoundTripIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
</PropertyGroup>
<ItemGroup>
<Compile Include="InternalMethodImplTest.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<!-- Needed for NativeAotIncompatible -->
<!-- Needed for NativeAotIncompatible, IlasmRoundTripIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<CLRTestPriority>1</CLRTestPriority>
<!-- Testing various TypeLoadExceptions -->
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- ildasm crashes on genmeth.dll. See https://github.com/dotnet/runtime/issues/127576 -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).il" />
Expand Down
6 changes: 6 additions & 0 deletions src/tests/run.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set __msbuildExtraArgs=
set __LongGCTests=
set __GCSimulatorTests=
set __IlasmRoundTrip=
set __UseManagedIlasm=
set __PrintLastResultsOnly=
set LogsDirArg=
set RunInUnloadableContext=
Expand Down Expand Up @@ -73,6 +74,7 @@ if /i "%1" == "gcstresslevel" (set DOTNET_GCStress=%2&
if /i "%1" == "gcsimulator" (set __GCSimulatorTests=1&shift&goto Arg_Loop)
if /i "%1" == "longgc" (set __LongGCTests=1&shift&goto Arg_Loop)
if /i "%1" == "ilasmroundtrip" (set __IlasmRoundTrip=1&shift&goto Arg_Loop)
if /i "%1" == "usemanagedilasm" (set __IlasmRoundTrip=1&set __UseManagedIlasm=1&shift&goto Arg_Loop)
if /i "%1" == "timeout" (set __TestTimeout=%2&shift&shift&goto Arg_Loop)
Comment thread
jkoritzinsky marked this conversation as resolved.
if /i "%1" == "runincontext" (set RunInUnloadableContext=1&shift&goto Arg_Loop)
if /i "%1" == "tieringtest" (set TieringTest=1&shift&goto Arg_Loop)
Expand Down Expand Up @@ -152,6 +154,10 @@ if defined __IlasmRoundTrip (
set __RuntestPyArgs=%__RuntestPyArgs% --ilasmroundtrip
)

if defined __UseManagedIlasm (
set __RuntestPyArgs=%__RuntestPyArgs% --use_managed_ilasm
)

if defined __TestEnv (
set __RuntestPyArgs=%__RuntestPyArgs% -test_env %__TestEnv%
)
Expand Down
15 changes: 15 additions & 0 deletions src/tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
parser.add_argument("--long_gc", dest="long_gc", action="store_true", default=False)
parser.add_argument("--gcsimulator", dest="gcsimulator", action="store_true", default=False)
parser.add_argument("--ilasmroundtrip", dest="ilasmroundtrip", action="store_true", default=False)
parser.add_argument("--use_managed_ilasm", dest="use_managed_ilasm", action="store_true", default=False)
parser.add_argument("--run_crossgen2_tests", dest="run_crossgen2_tests", action="store_true", default=False)
parser.add_argument("--large_version_bubble", dest="large_version_bubble", action="store_true", default=False)
parser.add_argument("--synthesize_pgo", dest="synthesize_pgo", action="store_true", default=False)
Expand Down Expand Up @@ -829,6 +830,15 @@ def run_tests(args,
print("Setting RunningIlasmRoundTrip=1")
os.environ["RunningIlasmRoundTrip"] = "1"

if args.use_managed_ilasm:
if not args.ilasmroundtrip:
print("--use_managed_ilasm implies --ilasmroundtrip; enabling ilasm round trip.")
print("Setting RunningIlasmRoundTrip=1")
os.environ["RunningIlasmRoundTrip"] = "1"
print("Using managed ILasm for round trip.")
print("Setting IlasmRoundTripUseManagedIlasm=1")
os.environ["IlasmRoundTripUseManagedIlasm"] = "1"
Comment thread
jkoritzinsky marked this conversation as resolved.

if args.run_crossgen2_tests:
print("Running tests R2R (Crossgen2)")
print("Setting RunCrossGen2=1")
Expand Down Expand Up @@ -978,6 +988,11 @@ def setup_args(args):
lambda arg: True,
"Error setting ilasmroundtrip")

coreclr_setup_args.verify(args,
"use_managed_ilasm",
lambda arg: True,
"Error setting use_managed_ilasm")

coreclr_setup_args.verify(args,
"large_version_bubble",
lambda arg: True,
Expand Down
Loading