Skip to content
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

Convert tests under GC subtree to the merged test model #92543

Merged
merged 18 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
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
4 changes: 3 additions & 1 deletion src/tests/GC/API/GC/Collect_neg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Xunit;

public class NegCollect
{
public static int Main()
[Fact]
public static int TestEntryPoint()
{
bool retVal = true;
GCCollectionMode[] invalidInputs = { (GCCollectionMode)(GCCollectionMode.Default - 1), (GCCollectionMode)(GCCollectionMode.Aggressive + 1) };
Expand Down
3 changes: 2 additions & 1 deletion src/tests/GC/API/GC/Collect_neg.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
Loading