Skip to content

Commit

Permalink
Convert JIT/opt to a merged test group (#85850)
Browse files Browse the repository at this point in the history
See https://github.com/markples/utils/tree/for-PR-dotnet-runtime-85847-others for ILTransform tool. In this group, I was a bit more aggressive in converting individual tests in [Fact]s and [Theory]s when needing to make manual changes. This required a change to the wrapper generator.

* Manual removal of C# Main args
* Mark async Main test as RPI
* Manual removal of IL Main arg
* Manual fix for badcallee
* [ILTransform -p] Remove _il from project name
* [ILTransform -n] Unique project names
* [ILTransform -m] Remove .module from IL tests
* Rename GitHub_42719: _r means not DebugType=Full, _o for optimize
* [ILTransform -a] Match IL .assembly names to project names
* [ILTransform -prociso] Set RequiresProcessIsolation when needed by other properties
* [ILTransform -sr] Use canonical form for .assembly extern System.Runtime
* [ILTransform -ilfact] Main->TestEntryPoint, [Fact], remove OutputType=Exe
* [ILTransform -public] Make test entrypoints accessible
* Manual fixes for [ILTransform -public] - internal methods to handle internal parameter types
* Handle float constants for InlineData in XUnitWrapperGenerator
* Manual fixes for xUnit1013 - internal methods, convert to [Theory]
* Manual fixes for xUnit1013 - internal methods, disable region
* Add merged group
* Fix mismatch{32,64} by putting the test methods in classes
  • Loading branch information
markples authored May 12, 2023
1 parent c2750cb commit 2c31cd7
Show file tree
Hide file tree
Showing 559 changed files with 1,389 additions and 1,014 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ private static ImmutableArray<ITestInfo> CreateTestCases(IMethodSymbol method, L
// Emit diagnostic
continue;
}
var argsAsCode = ImmutableArray.CreateRange(args.Select(a => a.ToCSharpString()));
var argsAsCode = ImmutableArray.CreateRange(args.Select(a => a.ToCSharpString() + (a.Type!.SpecialType == SpecialType.System_Single ? "F" : "")));
testCasesBuilder.Add(new BasicTestMethod(method, alias, arguments: argsAsCode));
break;
}
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/Add/IntAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

namespace CodeGenTests
{
static class IntAdd
public static class IntAdd
{
[MethodImpl(MethodImplOptions.NoInlining)]
static sbyte Int8_Add(sbyte x, sbyte y)
Expand Down Expand Up @@ -86,7 +87,8 @@ static ulong UInt64_Add(ulong x, ulong y)
return x + y;
}

static int Main()
[Fact]
public static int TestEntryPoint()
{
// Int8
if (Int8_Add(SByte.MaxValue, 15) != -114)
Expand Down
3 changes: 2 additions & 1 deletion src/tests/JIT/opt/Add/IntAdd.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for CLRTestEnvironmentVariable -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/And/IntAnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

namespace CodeGenTests
{
class IntAnd
public class IntAnd
{
[MethodImpl(MethodImplOptions.NoInlining)]
static void SideEffect()
Expand Down Expand Up @@ -70,7 +71,8 @@ static uint Test_And_UInt32_MaxValue(uint i)
return i & UInt32.MaxValue;
}

static int Main()
[Fact]
public static int TestEntryPoint()
{
// No CastByte
if (!Test_UInt32_UInt32_And(0b1000_0000_0000_0000_0000_0000_0000_0000, 0b0000_0000_0000_0000_0000_0000_0000_0001))
Expand Down
3 changes: 2 additions & 1 deletion src/tests/JIT/opt/And/IntAnd.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for CLRTestEnvironmentVariable -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
Expand Down
12 changes: 0 additions & 12 deletions src/tests/JIT/opt/And/Regressions/Regression1.csproj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//
// File: D:\a\_work\1\s\src\coreclr\jit\lowerxarch.cpp Line: 5118
//
using Xunit;
public class Program
{
public static bool s_26;
public static int Main()
[Fact]
public static int TestEntryPoint()
{
var vr2 = new uint[,] { { 0 } };
int vr7 = default(int);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/ArrBoundBinaryOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Xunit;

class Program
public class Program
{
private static int returnCode = 100;

public static int Main()
[Fact]
public static int TestEntryPoint()
{
int[] testIndices = Enumerable.Range(-50, 50)
// also add some corner case values
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<!-- Disabled for GCStress due to test failure tracked by https://github.com/dotnet/runtime/issues/66279 -->
<GCStressIncompatible>true</GCStressIncompatible>
</PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/ArrBoundElim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

class Program
public class Program
{
private static int returnCode = 100;

public static int Main()
[Fact]
public static int TestEntryPoint()
{
RunTestThrows(Tests.MulOutsideRange);
RunTestThrows(Tests.MulOverflow);
Expand Down
3 changes: 0 additions & 3 deletions src/tests/JIT/opt/AssertionPropagation/ArrBoundElim.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/ArrBoundMinLength.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

class Program
public class Program
{
private static int returnCode = 100;

private static int[] arr = new int[6];

public static int Main()
[Fact]
public static int TestEntryPoint()
{
RunTestThrows(Tests.GreaterOutOfBound);
RunTestThrows(Tests.GreaterEqualOutOfBound);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/ArrBoundUnsigned.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

class ArrBoundUnsigned
public class ArrBoundUnsigned
{
// The method names indicate when the array access takes place e.g i_LT_UN_len executes a[i] if (uint)i < (uint)a.len.
// If the condition is true and the array index is invalid then an IndexOutOfRangeException is expected.
Expand Down Expand Up @@ -300,7 +301,8 @@ static int i_GE_UN_len_next_edge(int[] a, int i, int lenTest)
return a[i];
}

static int Main()
[Fact]
public static int TestEntryPoint()
{
const int Pass = 100;
const int Fail = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. -->
<DebugType>None</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/CPropOverflow.il
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class private auto ansi beforefieldinit Sample1
.class public auto ansi beforefieldinit Sample1
extends [mscorlib]System.Object
{
.method private hidebysig static int32
Expand All @@ -63,7 +63,7 @@
IL_0018: ret
} // end of method Sample1::OverflowTest

.method private hidebysig static int32
.method public hidebysig static int32
Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/ConstantProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
//Simple dev unit test for constant propagation assertion.

using System;
using Xunit;

internal class Sample1
public class Sample1
{
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static int func(int a)
Expand All @@ -18,7 +19,8 @@ private static int func(int a)
else
return y;
}
private static int Main()
[Fact]
public static int TestEntryPoint()
{
bool failed = false;
if (func(0) != 5)
Expand Down
1 change: 0 additions & 1 deletion src/tests/JIT/opt/AssertionPropagation/ConstantProp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/CopyProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
//Unit test for copy propagation assertion.

using System;
using Xunit;

internal class Sample2
public class Sample2
{
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static sbyte func(int a, int b)
Expand All @@ -21,7 +22,8 @@ private static sbyte func(int a, int b)
return (sbyte)res;
}

private static int Main()
[Fact]
public static int TestEntryPoint()
{
bool failed = false;
if (func(1, 2) != -1)
Expand Down
1 change: 0 additions & 1 deletion src/tests/JIT/opt/AssertionPropagation/CopyProp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

using System;
using System.Runtime.CompilerServices;
using Xunit;

public class DynBlkNullAssertions
{
public static int Main()
[Fact]
public static int TestEntryPoint()
{
if (!TestCpBlk(ref Unsafe.NullRef<byte>(), ref Unsafe.NullRef<byte>(), 0))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
//Unit test for null check assertion.

using System;
using Xunit;

internal class Sample3
public class Sample3
{
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static void func(object o)
Expand All @@ -15,7 +16,8 @@ private static void func(object o)
o.GetType();
}

private static int Main()
[Fact]
public static int TestEntryPoint()
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Xunit;

internal class Sample4
public class Sample4
{
private static int s_s = 1;

Expand All @@ -19,7 +20,8 @@ private static void func(object o1, object o2)
}
}

private static int Main()
[Fact]
public static int TestEntryPoint()
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//Unit test for Null check assertion propagation.

using System;
using Xunit;

internal class Point
{
Expand All @@ -16,7 +17,7 @@ internal class Point
public int Distance() { return x * x + y * y; }
}

internal class Sample5
public class Sample5
{
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static int func(Point p1, Point p2, Point p3)
Expand All @@ -36,7 +37,8 @@ private static int func(Point p1, Point p2, Point p3)
return h;
}

private static int Main()
[Fact]
public static int TestEntryPoint()
{
try
{
Expand Down
Loading

0 comments on commit 2c31cd7

Please sign in to comment.