Skip to content

Commit 2c31cd7

Browse files
authored
Convert JIT/opt to a merged test group (#85850)
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
1 parent c2750cb commit 2c31cd7

File tree

559 files changed

+1389
-1014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

559 files changed

+1389
-1014
lines changed

src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ private static ImmutableArray<ITestInfo> CreateTestCases(IMethodSymbol method, L
767767
// Emit diagnostic
768768
continue;
769769
}
770-
var argsAsCode = ImmutableArray.CreateRange(args.Select(a => a.ToCSharpString()));
770+
var argsAsCode = ImmutableArray.CreateRange(args.Select(a => a.ToCSharpString() + (a.Type!.SpecialType == SpecialType.System_Single ? "F" : "")));
771771
testCasesBuilder.Add(new BasicTestMethod(method, alias, arguments: argsAsCode));
772772
break;
773773
}

src/tests/JIT/opt/Add/IntAdd.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
using System;
55
using System.Runtime.CompilerServices;
6+
using Xunit;
67

78
namespace CodeGenTests
89
{
9-
static class IntAdd
10+
public static class IntAdd
1011
{
1112
[MethodImpl(MethodImplOptions.NoInlining)]
1213
static sbyte Int8_Add(sbyte x, sbyte y)
@@ -86,7 +87,8 @@ static ulong UInt64_Add(ulong x, ulong y)
8687
return x + y;
8788
}
8889

89-
static int Main()
90+
[Fact]
91+
public static int TestEntryPoint()
9092
{
9193
// Int8
9294
if (Int8_Add(SByte.MaxValue, 15) != -114)

src/tests/JIT/opt/Add/IntAdd.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
3+
<!-- Needed for CLRTestEnvironmentVariable -->
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
45
</PropertyGroup>
56
<PropertyGroup>
67
<DebugType>None</DebugType>

src/tests/JIT/opt/And/IntAnd.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
using System;
55
using System.Runtime.CompilerServices;
6+
using Xunit;
67

78
namespace CodeGenTests
89
{
9-
class IntAnd
10+
public class IntAnd
1011
{
1112
[MethodImpl(MethodImplOptions.NoInlining)]
1213
static void SideEffect()
@@ -70,7 +71,8 @@ static uint Test_And_UInt32_MaxValue(uint i)
7071
return i & UInt32.MaxValue;
7172
}
7273

73-
static int Main()
74+
[Fact]
75+
public static int TestEntryPoint()
7476
{
7577
// No CastByte
7678
if (!Test_UInt32_UInt32_And(0b1000_0000_0000_0000_0000_0000_0000_0000, 0b0000_0000_0000_0000_0000_0000_0000_0001))

src/tests/JIT/opt/And/IntAnd.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
3+
<!-- Needed for CLRTestEnvironmentVariable -->
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
45
</PropertyGroup>
56
<PropertyGroup>
67
<DebugType>None</DebugType>

src/tests/JIT/opt/And/Regressions/Regression1.csproj

-12
This file was deleted.

src/tests/JIT/opt/And/Regressions/Regression1.cs src/tests/JIT/opt/And/Regressions/Regression1_And.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
//
88
// File: D:\a\_work\1\s\src\coreclr\jit\lowerxarch.cpp Line: 5118
99
//
10+
using Xunit;
1011
public class Program
1112
{
1213
public static bool s_26;
13-
public static int Main()
14+
[Fact]
15+
public static int TestEntryPoint()
1416
{
1517
var vr2 = new uint[,] { { 0 } };
1618
int vr7 = default(int);

src/tests/JIT/opt/IsKnownConstant/StringEquals.csproj src/tests/JIT/opt/And/Regressions/Regression1_And.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
3+
<DebugType>None</DebugType>
44
<Optimize>True</Optimize>
55
</PropertyGroup>
66
<ItemGroup>

src/tests/JIT/opt/AssertionPropagation/ArrBoundBinaryOp.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Runtime.CompilerServices;
8+
using Xunit;
89

9-
class Program
10+
public class Program
1011
{
1112
private static int returnCode = 100;
1213

13-
public static int Main()
14+
[Fact]
15+
public static int TestEntryPoint()
1416
{
1517
int[] testIndices = Enumerable.Range(-50, 50)
1618
// also add some corner case values

src/tests/JIT/opt/AssertionPropagation/ArrBoundBinaryOp.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
3+
<!-- Needed for GCStressIncompatible -->
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
45
<!-- Disabled for GCStress due to test failure tracked by https://github.com/dotnet/runtime/issues/66279 -->
56
<GCStressIncompatible>true</GCStressIncompatible>
67
</PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/ArrBoundElim.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
using System;
55
using System.Runtime.CompilerServices;
6+
using Xunit;
67

7-
class Program
8+
public class Program
89
{
910
private static int returnCode = 100;
1011

11-
public static int Main()
12+
[Fact]
13+
public static int TestEntryPoint()
1214
{
1315
RunTestThrows(Tests.MulOutsideRange);
1416
RunTestThrows(Tests.MulOverflow);

src/tests/JIT/opt/AssertionPropagation/ArrBoundElim.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
</PropertyGroup>
52
<PropertyGroup>
63
<DebugType>None</DebugType>
74
<Optimize>True</Optimize>

src/tests/JIT/opt/AssertionPropagation/ArrBoundMinLength.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
using System;
55
using System.Runtime.CompilerServices;
6+
using Xunit;
67

7-
class Program
8+
public class Program
89
{
910
private static int returnCode = 100;
1011

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

13-
public static int Main()
14+
[Fact]
15+
public static int TestEntryPoint()
1416
{
1517
RunTestThrows(Tests.GreaterOutOfBound);
1618
RunTestThrows(Tests.GreaterEqualOutOfBound);

src/tests/JIT/opt/AssertionPropagation/ArrBoundMinLength.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
</PropertyGroup>
52
<PropertyGroup>
63
<DebugType>None</DebugType>
74
<Optimize>True</Optimize>

src/tests/JIT/opt/AssertionPropagation/ArrBoundUnsigned.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
using System;
77
using System.Runtime.CompilerServices;
8+
using Xunit;
89

9-
class ArrBoundUnsigned
10+
public class ArrBoundUnsigned
1011
{
1112
// 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.
1213
// If the condition is true and the array index is invalid then an IndexOutOfRangeException is expected.
@@ -300,7 +301,8 @@ static int i_GE_UN_len_next_edge(int[] a, int i, int lenTest)
300301
return a[i];
301302
}
302303

303-
static int Main()
304+
[Fact]
305+
public static int TestEntryPoint()
304306
{
305307
const int Pass = 100;
306308
const int Fail = -1;

src/tests/JIT/opt/AssertionPropagation/ArrBoundUnsigned.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
</PropertyGroup>
52
<PropertyGroup>
63
<!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. -->
74
<DebugType>None</DebugType>

src/tests/JIT/opt/AssertionPropagation/CPropOverflow.il

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
// =============== CLASS MEMBERS DECLARATION ===================
3939

40-
.class private auto ansi beforefieldinit Sample1
40+
.class public auto ansi beforefieldinit Sample1
4141
extends [mscorlib]System.Object
4242
{
4343
.method private hidebysig static int32
@@ -63,7 +63,7 @@
6363
IL_0018: ret
6464
} // end of method Sample1::OverflowTest
6565

66-
.method private hidebysig static int32
66+
.method public hidebysig static int32
6767
Main() cil managed
6868
{
6969
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (

src/tests/JIT/opt/AssertionPropagation/CPropOverflow.ilproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk.IL">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/ConstantProp.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
//Simple dev unit test for constant propagation assertion.
55

66
using System;
7+
using Xunit;
78

8-
internal class Sample1
9+
public class Sample1
910
{
1011
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
1112
private static int func(int a)
@@ -18,7 +19,8 @@ private static int func(int a)
1819
else
1920
return y;
2021
}
21-
private static int Main()
22+
[Fact]
23+
public static int TestEntryPoint()
2224
{
2325
bool failed = false;
2426
if (func(0) != 5)

src/tests/JIT/opt/AssertionPropagation/ConstantProp.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/CopyProp.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
//Unit test for copy propagation assertion.
55

66
using System;
7+
using Xunit;
78

8-
internal class Sample2
9+
public class Sample2
910
{
1011
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
1112
private static sbyte func(int a, int b)
@@ -21,7 +22,8 @@ private static sbyte func(int a, int b)
2122
return (sbyte)res;
2223
}
2324

24-
private static int Main()
25+
[Fact]
26+
public static int TestEntryPoint()
2527
{
2628
bool failed = false;
2729
if (func(1, 2) != -1)

src/tests/JIT/opt/AssertionPropagation/CopyProp.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/DynBlkNullAssertions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
using System;
99
using System.Runtime.CompilerServices;
10+
using Xunit;
1011

1112
public class DynBlkNullAssertions
1213
{
13-
public static int Main()
14+
[Fact]
15+
public static int TestEntryPoint()
1416
{
1517
if (!TestCpBlk(ref Unsafe.NullRef<byte>(), ref Unsafe.NullRef<byte>(), 0))
1618
{

src/tests/JIT/opt/AssertionPropagation/DynBlkNullAssertions.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion1.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
//Unit test for null check assertion.
55

66
using System;
7+
using Xunit;
78

8-
internal class Sample3
9+
public class Sample3
910
{
1011
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
1112
private static void func(object o)
@@ -15,7 +16,8 @@ private static void func(object o)
1516
o.GetType();
1617
}
1718

18-
private static int Main()
19+
[Fact]
20+
public static int TestEntryPoint()
1921
{
2022
try
2123
{

src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion1.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion2.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using Xunit;
56

6-
internal class Sample4
7+
public class Sample4
78
{
89
private static int s_s = 1;
910

@@ -19,7 +20,8 @@ private static void func(object o1, object o2)
1920
}
2021
}
2122

22-
private static int Main()
23+
[Fact]
24+
public static int TestEntryPoint()
2325
{
2426
try
2527
{

src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion2.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
43
<CLRTestPriority>1</CLRTestPriority>
54
</PropertyGroup>
65
<PropertyGroup>

src/tests/JIT/opt/AssertionPropagation/NullCheckAssertion3.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//Unit test for Null check assertion propagation.
55

66
using System;
7+
using Xunit;
78

89
internal class Point
910
{
@@ -16,7 +17,7 @@ internal class Point
1617
public int Distance() { return x * x + y * y; }
1718
}
1819

19-
internal class Sample5
20+
public class Sample5
2021
{
2122
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
2223
private static int func(Point p1, Point p2, Point p3)
@@ -36,7 +37,8 @@ private static int func(Point p1, Point p2, Point p3)
3637
return h;
3738
}
3839

39-
private static int Main()
40+
[Fact]
41+
public static int TestEntryPoint()
4042
{
4143
try
4244
{

0 commit comments

Comments
 (0)