Skip to content

Commit

Permalink
Convert tests under GC subtree to the merged test model (dotnet#92543)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
  • Loading branch information
2 people authored and jtschuster committed Sep 17, 2024
1 parent 497ed34 commit e6a38f7
Show file tree
Hide file tree
Showing 763 changed files with 3,400 additions and 937 deletions.
8 changes: 4 additions & 4 deletions eng/pipelines/common/templates/runtimes/build-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ jobs:
- name: runtimeFlavorArgs
value: '-nativeaot'

- name: testTreeFilterArg
- name: testFilterArg
value: ''

# Only build GCSimulator tests when the gc-simulator group is specified.
- ${{ if eq(parameters.testGroup, 'gc-simulator') }}:
- name: testTreeFilterArg
value: 'tree GC/Scenarios/GCSimulator'
- name: testFilterArg
value: 'test GC/Scenarios/GC-simulator.csproj'

- template: /eng/pipelines/common/templates/runtimes/native-test-assets-variables.yml
parameters:
Expand All @@ -110,7 +110,7 @@ jobs:
displayName: Disk Usage before Build
# Build managed test components
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)Managed allTargets skipnative skipgeneratelayout skiptestwrappers $(buildConfig) $(archType) $(runtimeFlavorArgs) $(crossArg) $(priorityArg) $(testTreeFilterArg) ci /p:TargetOS=AnyOS
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)Managed allTargets skipnative skipgeneratelayout skiptestwrappers $(buildConfig) $(archType) $(runtimeFlavorArgs) $(crossArg) $(priorityArg) $(testFilterArg) ci /p:TargetOS=AnyOS
displayName: Build managed test components

- ${{ if in(parameters.osGroup, 'osx', 'ios', 'tvos') }}:
Expand Down
8 changes: 4 additions & 4 deletions eng/pipelines/common/templates/runtimes/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ jobs:
- name: LogNamePrefix
value: TestRunLogs_R2R_CG2_HotColdSplitting

- name: testTreeFilterArg
- name: testFilterArg
value: ''

# Only build GCSimulator tests when the gc-simulator group is specified.
- ${{ if eq(parameters.testGroup, 'gc-simulator') }}:
- name: testTreeFilterArg
value: 'tree GC/Scenarios/GCSimulator'
- name: testFilterArg
value: 'test GC/Scenarios/GC-simulator.csproj'

- template: /eng/pipelines/common/templates/runtimes/native-test-assets-variables.yml
parameters:
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
# and directly unzip them there after download). Unfortunately the logic to copy
# the native artifacts to the final test folders is dependent on availability of the
# managed test artifacts. This step also generates the final test execution scripts.
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) copynativeonly $(logRootNameArg)Native $(testTreeFilterArg) $(runtimeFlavorArgs) $(crossgenArg) $(buildConfig) $(archType) $(priorityArg) $(librariesOverrideArg) $(codeFlowEnforcementArg)
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) copynativeonly $(logRootNameArg)Native $(testFilterArg) $(runtimeFlavorArgs) $(crossgenArg) $(buildConfig) $(archType) $(priorityArg) $(librariesOverrideArg) $(codeFlowEnforcementArg)
displayName: Copy native test components to test output folder


Expand Down
7 changes: 4 additions & 3 deletions src/tests/GC/API/Frozen/Frozen.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;
namespace HelloFrozenSegment
{
using System;
Expand Down Expand Up @@ -134,9 +135,10 @@ internal class Node
public int number;
}

internal static class Program
public static class Program
{
private static unsafe int Main()
[Fact]
public static unsafe void TestEntryPoint()
{
// Regression testing for dotnet/runtime #83027
Node[] firstArray = new Node[30000000];
Expand Down Expand Up @@ -180,7 +182,6 @@ private static unsafe int Main()
GC.Collect();
Console.WriteLine(root.next.next != null);
frozenSegment.Release();
return 100;
}
}
}
3 changes: 2 additions & 1 deletion src/tests/GC/API/Frozen/Frozen.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 CLRTestTargetUnsupported, GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
<CLRTestPriority>1</CLRTestPriority>
<GCStressIncompatible>true</GCStressIncompatible>
Expand Down
35 changes: 19 additions & 16 deletions src/tests/GC/API/GC/Collect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@
// Tests GC.Collect()

using System;
using Xunit;

public class Test_Collect {
public static int Main() {
[Fact]
public static int TestEntryPoint()
{

Object obj1 = new Object();
int[] array = new int[25];
int gen1 = GC.GetGeneration(array);
Object obj1 = new Object();
int[] array = new int[25];
int gen1 = GC.GetGeneration(array);

Console.WriteLine("Array is in generation: " + gen1);
GC.Collect();
Console.WriteLine("Array is in generation: " + gen1);
GC.Collect();

int gen2 = GC.GetGeneration(array);
Console.WriteLine("Array is in generation: " + gen2);
int gen2 = GC.GetGeneration(array);
Console.WriteLine("Array is in generation: " + gen2);

if(((gen1==2) && (gen2==2)) || (gen2>gen1)) { // was already in gen 2!
Console.WriteLine("Test for GC.Collect() passed!");
if(((gen1==2) && (gen2==2)) || (gen2>gen1)) { // was already in gen 2!
Console.WriteLine("Test for GC.Collect() passed!");
return 100;
}
}

else {
Console.WriteLine("Test for GC.Collect() failed!");
else {
Console.WriteLine("Test for GC.Collect() failed!");
return 1;
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect.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 GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<CLRTestPriority>1</CLRTestPriority>
<GCStressIncompatible>true</GCStressIncompatible>
</PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/GC/API/GC/Collect0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// Tests GC.Collect(0)

using System;
using Xunit;

public class Test_Collect0 {
public static int Main() {
[Fact]
public static int TestEntryPoint() {

int[] array = new int[25];
int agen1 = GC.GetGeneration(array);
Expand Down
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect0.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 GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/GC/API/GC/Collect1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
// Tests GC.Collect(1)

using System;
using Xunit;

public class Test_Collect1
{
public static int Main()
[Fact]
public static int TestEntryPoint()
{
int[] array = new int[25];
int agen1 = GC.GetGeneration(array);
Expand Down
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect1.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 GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/GC/API/GC/Collect_Aggressive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Xunit;

public class AggressiveCollect
{
public static int Main()
[Fact]
public static int TestEntryPoint()
{
long before = CreateGarbage();
GC.Collect(2, GCCollectionMode.Aggressive, blocking: true, compacting: true);
Expand Down
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect_Aggressive.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 CLRTestTargetUnsupported -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<!-- Consider enable it for Mono whenever the implementation is ready -->
<!-- https://github.com/dotnet/runtime/issues/73167 -->
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
Expand Down
5 changes: 3 additions & 2 deletions src/tests/GC/API/GC/Collect_Aggressive_MultipleParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Xunit;

public class AggressiveCollect_MultipleParameters
{
public static int Main()
[Fact]
public static void TestEntryPoint()
{
long before = CreateGarbage();
GC.Collect(2, GCCollectionMode.Aggressive, blocking: true, compacting: true);
Expand Down Expand Up @@ -55,7 +57,6 @@ public static int Main()
}

// If we got this far, we have successfully executed all the tests.
return 100;
}

[MethodImpl(MethodImplOptions.NoInlining)]
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 CLRTestTargetUnsupported -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<!-- Consider enable it for Mono whenever the implementation is ready -->
<!-- https://github.com/dotnet/runtime/issues/73167 -->
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Default_1.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>0</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Default_2.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>1</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Default_3.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>2</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Forced_1.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>0</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Forced_2.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>1</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Forced_3.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for GCStressIncompatible -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>2</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/tests/GC/API/GC/Collect_Optimized_1.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>0</CLRTestExecutionArguments>

<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/tests/GC/API/GC/Collect_Optimized_2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>1</CLRTestExecutionArguments>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/tests/GC/API/GC/Collect_Optimized_3.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>

<!-- Test needs explicit Main as it uses command-line parameters -->
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
<CLRTestExecutionArguments>2</CLRTestExecutionArguments>
</PropertyGroup>
<PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/GC/API/GC/Collect_fail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
*/

using System;
using Xunit;

public class Test_Collect_fail
{
public static int Main()
[Fact]
public static int TestEntryPoint()
{
int[] array = new int[25];
bool passed = false;
Expand Down
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect_fail.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 mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
Expand Down
Loading

0 comments on commit e6a38f7

Please sign in to comment.