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

Move many interop tests to run in-proc and move many to built in the merged runner itself #94109

Merged
merged 24 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
db96edf
Merge 8 subfolders of Interop into the merged runner itself. Remove s…
jkoritzinsky Oct 27, 2023
86c426b
Add a CMakeProjectReference from the merged runner to all subdirector…
jkoritzinsky Oct 27, 2023
fed19d8
Convert another test suite to in-process test execution.
jkoritzinsky Oct 27, 2023
dde487a
Fix build
jkoritzinsky Oct 27, 2023
1821e39
Update based on merged PR.
jkoritzinsky Oct 27, 2023
a85f7ed
Convert GenericsTest to use the merged runner.
jkoritzinsky Oct 27, 2023
c603638
Move most of Interop/PInvoke in-assembly to reduce the number of asse…
jkoritzinsky Oct 27, 2023
97605a3
Remove duplicate CMake project reference.
jkoritzinsky Oct 27, 2023
b14beee
Handle building tests with native assets that are excluded on non-Win…
jkoritzinsky Oct 27, 2023
30379bf
Add ActiveIssues
jkoritzinsky Oct 27, 2023
53a89e5
Merge branch 'main' into interop-tests-merge
jkoritzinsky Nov 22, 2023
52e5485
Port over more test disables from issues.targets to try to get more t…
jkoritzinsky Nov 22, 2023
7b2d481
Merge branch 'main' of github.com:dotnet/runtime into interop-tests-m…
jkoritzinsky Nov 27, 2023
1af19cd
Fix OuterLoop attribute handling
jkoritzinsky Nov 27, 2023
0e49593
Fix ActiveIssue entries for NativeAOT
jkoritzinsky Nov 27, 2023
26230da
Remove extraneous edit
jkoritzinsky Nov 27, 2023
893eb61
Disable SafeHandle tests that fail on Mono
jkoritzinsky Nov 29, 2023
124e34f
Disable last failing test on NativeAOT
jkoritzinsky Nov 29, 2023
9bfe33c
Merge branch 'main' into interop-tests-merge
jkoritzinsky Nov 29, 2023
7d69f4e
Merge branch 'main' of github.com:dotnet/runtime into interop-tests-m…
jkoritzinsky Nov 30, 2023
dc096ae
Merge branch 'interop-tests-merge' of github.com:jkoritzinsky/runtime…
jkoritzinsky Nov 30, 2023
7b6a028
Disable remaining tests that fail on Mono on non-mobile platforms.
jkoritzinsky Nov 30, 2023
b623ce9
Disable Interop tests with native assets on platforms that we don't c…
jkoritzinsky Dec 6, 2023
c8099ee
PR feedback
jkoritzinsky Dec 7, 2023
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
4 changes: 4 additions & 0 deletions src/tests/Common/CoreCLRTestLibrary/PlatformDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ public static bool IsNonZeroLowerBoundArraySupported
public static bool IsMonoLLVMAOT => _variant == "llvmaot";
public static bool IsMonoLLVMFULLAOT => _variant == "llvmfullaot";
public static bool IsMonoInterpreter => _variant == "monointerpreter";

// These platforms have not had their infrastructure updated to support native test assets.
public static bool PlatformDoesNotSupportNativeTestAssets =>
OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS() || OperatingSystem.IsAndroid() || OperatingSystem.IsBrowser() || OperatingSystem.IsWasi();
}
}
27 changes: 27 additions & 0 deletions src/tests/Common/CoreCLRTestLibrary/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static bool Verbose
public static bool IsX64 => (RuntimeInformation.ProcessArchitecture == Architecture.X64);
public static bool IsArm => (RuntimeInformation.ProcessArchitecture == Architecture.Arm);
public static bool IsArm64 => (RuntimeInformation.ProcessArchitecture == Architecture.Arm64);
public static bool IsXArch => IsX86 || IsX64;

public static bool IsWindows => OperatingSystem.IsWindows();
public static bool IsLinux => OperatingSystem.IsLinux();
Expand Down Expand Up @@ -95,6 +96,7 @@ public static bool IsWindowsIoTCore
public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null;
public static bool IsNotMonoRuntime => !IsMonoRuntime;
public static bool IsNativeAot => IsNotMonoRuntime && !IsReflectionEmitSupported;
public static bool IsNotNativeAot => !IsNativeAot;

public static bool HasAssemblyFiles => !string.IsNullOrEmpty(typeof(Utilities).Assembly.Location);
public static bool IsSingleFile => !HasAssemblyFiles;
Expand Down Expand Up @@ -456,5 +458,30 @@ public static int ExecuteAndUnload(string assemblyPath, string[] args, Action<As

return exitCode;
}

private static void ExecuteAndUnloadInternal(string assemblyPath, string typeName, string methodName, object[] args, out WeakReference alcWeakRef)
{
AssemblyLoadContext alc = new AssemblyLoadContext($"[{assemblyPath}]{typeName}.{methodName}", true);
alcWeakRef = new WeakReference(alc);

Assembly asm = alc.LoadFromAssemblyPath(assemblyPath);
Type testType = asm.GetType(typeName);
testType.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static).Invoke(null, args);
alc.Unload();
}

public static void ExecuteAndUnload(string assemblyPath, string typeName, string methodName, params object[] args)
{
WeakReference alcWeakRef;
ExecuteAndUnloadInternal(assemblyPath, typeName, methodName, args, out alcWeakRef);

for (int i = 0; i < 8 && alcWeakRef.IsAlive; i++)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}

Assert.False(alcWeakRef.IsAlive);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using TestLibrary;
using Xunit;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class MarshalBoolArray
{
#region"variable"
Expand Down Expand Up @@ -78,7 +79,7 @@ private static bool TestMethod_CallBackOut(int size, bool[] array)
[DllImport("MarshalBoolArrayNative")]
private static extern bool DoCallBackInOut(CallBackInOut callback);
private delegate bool CallBackInOut([In]int size, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1, SizeConst = SIZE)] bool[] array);

private static bool TestMethod_CallBackInOut(int size, bool[] array)
{
bool retVal = true;
Expand Down Expand Up @@ -115,7 +116,7 @@ private static bool TestMethod_CallBackInOut(int size, bool[] array)
[DllImport("MarshalBoolArrayNative")]
private static extern bool DoCallBackRefIn(CallBackRefIn callback);
private delegate bool CallBackRefIn([In]int size, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)] ref bool[] array);

private static bool TestMethod_CallBackRefIn(int size, ref bool[] array)
{
bool retVal = true;
Expand All @@ -129,7 +130,7 @@ private static bool TestMethod_CallBackRefIn(int size, ref bool[] array)
//Since now the sizeconst doesnt support on ref,so only check the first item instead.
//Unhandled Exception: System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #2': Cannot use SizeParamIndex for ByRef array parameters.
//for (int i = 0; i < size; ++i) //Reverse PInvoke, true,false,true false,true
//{
//{
// if ((0 == i % 2) && !array[i])
// {
// ReportFailure("Failed on the Managed Side:TestMethod_CallBackRefIn. The " + (i + 1) + "st Item failed", true.ToString(), false.ToString());
Expand All @@ -152,7 +153,7 @@ private static bool TestMethod_CallBackRefIn(int size, ref bool[] array)
[DllImport("MarshalBoolArrayNative")]
private static extern bool DoCallBackRefOut(CallBackRefOut callback);
private delegate bool CallBackRefOut([In]int size, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] out bool[] array);

private static bool TestMethod_CallBackRefOut(int size, out bool[] array)
{
bool retVal = true;
Expand All @@ -175,7 +176,7 @@ private static bool TestMethod_CallBackRefOut(int size, out bool[] array)
[DllImport("MarshalBoolArrayNative")]
private static extern bool DoCallBackRefInOut(CallBackRefInOut callback);
private delegate bool CallBackRefInOut([In]int size, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)] ref bool[] array);

private static bool TestMethod_CallBackRefInOut(int size, ref bool[] array)
{
bool retVal = true;
Expand Down Expand Up @@ -219,10 +220,11 @@ private static bool TestMethod_CallBackRefInOut(int size, ref bool[] array)

[System.Security.SecuritySafeCritical]
[Fact]
[OuterLoop]
public static void TestEntryPoint()
{
bool retVal = true;

//TestFramework.BeginScenario("Reverse PInvoke with In attribute");
if (!DoCallBackIn(new CallBackIn(TestMethod_CallBackIn)))
{
Expand Down

This file was deleted.

6 changes: 4 additions & 2 deletions src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

#pragma warning disable CS0612, CS0618

public class Tester
[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class SafeArrayMarshallingTest
{
[Fact]
[ConditionalFact(typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.IsBuiltInComEnabled))]
[SkipOnMono("Requires COM support")]
public static int TestEntryPoint()
{
try
Expand Down
15 changes: 0 additions & 15 deletions src/tests/Interop/ArrayMarshalling/SafeArray/SafeArrayTest.csproj

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions src/tests/Interop/BestFitMapping/BestFitMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using TestLibrary;
using Xunit;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class BestFitMapping
{

Expand Down
4 changes: 4 additions & 0 deletions src/tests/Interop/COM/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
<!-- The tests are unhappy with where we lay out the executable -->
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- We must run these apps from this project as an entrypoint. -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>

<PropertyGroup Condition="'$(UseManagedCOMServer)' == 'true'">
<CLRTestScriptLocalCoreShim>true</CLRTestScriptLocalCoreShim>
<RequiresMockHostPolicy>true</RequiresMockHostPolicy>
<!-- These tests modify the global runtime state with the mock host policy. -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for mechanical merging of all remaining tests, this particular project may not actually need process isolation -->
<!-- Uses a custom AppManifest -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<ApplicationManifest>App.manifest</ApplicationManifest>
<UseManagedCOMServer>true</UseManagedCOMServer>
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Interop/COM/NativeClients/DefaultInterfaces.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CMakeProjectReference -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<CMakeProjectReference Include="DefaultInterfaces/CMakeLists.txt" />
<ProjectReference Include="../NETServer/NETServer.DefaultInterfaces.ilproj" />
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Interop/COM/NativeClients/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
<CLRTestIsHosted>false</CLRTestIsHosted>
<NativeAotIncompatible>true</NativeAotIncompatible>
<!-- The true entrypoint for these tests is a native executable -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Interop/COM/NativeClients/Dispatch.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CMakeProjectReference -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<CMakeProjectReference Include="Dispatch/CMakeLists.txt" />
<ProjectReference Include="../NETServer/NETServer.csproj" />
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Interop/COM/NativeClients/Events.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CMakeProjectReference -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<CMakeProjectReference Include="Events/CMakeLists.txt" />
<ProjectReference Include="../NETServer/NETServer.csproj" />
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Interop/COM/NativeClients/Licensing.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CMakeProjectReference -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<CMakeProjectReference Include="Licensing/CMakeLists.txt" />
<ProjectReference Include="../NETServer/NETServer.csproj" />
Expand Down
4 changes: 0 additions & 4 deletions src/tests/Interop/COM/NativeClients/Primitives.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CMakeProjectReference -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<CMakeProjectReference Include="Primitives/CMakeLists.txt" />
<ProjectReference Include="../NETServer/NETServer.csproj" />
Expand Down
1 change: 1 addition & 0 deletions src/tests/Interop/DisabledRuntimeMarshalling/AutoLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace DisabledRuntimeMarshalling;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class PInvokes_AutoLayout
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace DisabledRuntimeMarshalling;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class FunctionPointers
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingDisabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class DelegatesFromExternalAssembly
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace DisabledRuntimeMarshalling;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class Generics
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingDisabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class PInvokes
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingDisabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class UnmanagedCallersOnly
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingEnabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class DelegatesFromExternalAssembly
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingEnabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class PInvokes
{
public static bool IsWindowsX86Process => OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.X86;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingDisabled;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public unsafe class UnmanagedCallersOnly
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.InteropServices;
using Xunit;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class Test
{
private const string RelativeSubdirectoryName = "RelativeNative";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for UnloadabilityIncompatible, CLRTestBashEnvironmentVariable, CMakeProjectReference -->
<!--
This test has dependencies on specific file layouts relative to the executable.
It also sets specific loader environment variables.
-->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<!-- The test cannot be run twice in the same process since it moves a native dll that it uses for pinvoke later -->
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Runtime.InteropServices;
using Xunit;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class ExactSpellingTest
{
class Ansi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.InteropServices;
using Xunit;

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class DllImportSearchPathsTest
{
private static string Subdirectory => Path.Combine(NativeLibraryToLoad.GetDirectory(), "subdirectory");
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Interop/ExecInDefAppDom/ExecInDefAppDom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FakeInjectedCode
static int ParseArgument(String argument) { return int.Parse(argument);}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public class Program
{
public static class NativeMethods
Expand Down Expand Up @@ -57,6 +58,7 @@ static int TestExecuteInAppDomain(string assemblyPath, string typeName, string m
}

[Fact]
[SkipOnMono("The legacy CoreCLR activation API is not supported on Mono.")]
public static int TestEntryPoint()
{
int result = 100;
Expand Down
Loading