Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/mono/msbuild/apple/build/AppleBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
<AppleAppBuilderRuntime Condition="'$(AppleAppBuilderRuntime)' == '' and '$(UseNativeAOTRuntime)' == 'true'">NativeAOT</AppleAppBuilderRuntime>
<AppleAppBuilderRuntime Condition="'$(AppleAppBuilderRuntime)' == '' and '$(UseMonoRuntime)' == 'false'">CoreCLR</AppleAppBuilderRuntime>
<AppleAppBuilderRuntime Condition="'$(AppleAppBuilderRuntime)' == ''">MonoVM</AppleAppBuilderRuntime>
<MainLibraryFileName Condition="'$(UseNativeAOTRuntime)' == 'true'"></MainLibraryFileName>
</PropertyGroup>

<AppleAppBuilderTask
Expand Down
1 change: 1 addition & 0 deletions src/tests/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
<AllRunnableTestPaths Remove="$(XunitTestBinBase)\**\run-v8.sh" Condition="'$(TargetArchitecture)' == 'wasm'" />
<AllRunnableTestPaths Remove="%(SkipTestDirsPaths.Identity)\**\*.$(TestScriptExtension)" />
<MergedAssemblyMarkerPaths Include="$(XunitTestBinBase)\**\*.MergedTestAssembly"/>
<MergedAssemblyMarkerPaths Include="$(XunitTestBinBase)\**\*.MergedTestAssemblyForStress"/>
<MergedAssemblyFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyMarkerPaths.Identity)'))" />
<MergedAssemblyParentFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyFolders.Identity)'))" />
<AllRunnableTestPaths Remove="%(MergedAssemblyParentFolders.Identity)\**\*.$(TestScriptExtension)" Condition="'@(MergedAssemblyParentFolders)' != ''" />
Expand Down
6 changes: 6 additions & 0 deletions src/tests/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
<PropertyGroup>
<!-- We expect trimming to be fully enabled in these tests -->
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>

<!--
Each of these tests is considered its own "merged runner" that contains merged-in tests.
This allows the tests to run on mobile platforms where process isolation is not supported.
-->
<HasMergedInTests>true</HasMergedInTests>
</PropertyGroup>
</Project>
13 changes: 13 additions & 0 deletions src/tests/nativeaot/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Treat these tests as merged test runners.
Many of these NativeAOT tests need to be their own executables to validate specific features,
but we want to run them on mobile platforms as well.
However, mobile platforms don't support tests that require process isolation, so we can't use RequiresProcessIsolation.
Instead, we treat these tests as merged test runners themselves, so that they can run on mobile platforms.
-->
<Import Condition="'$(CLRTestKind)' != 'SharedLibrary'" Project="$(TestSourceDir)MergedTestRunner.targets" />

<!-- SDK Style projects auto-magically include this file. -->
<Import Project="..\Directory.Build.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,56 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xunit;

namespace GenerateUnmanagedEntryPoints
{
unsafe class Program
unsafe class Tests : IDisposable
{
[UnmanagedCallersOnly(EntryPoint = "MainAssemblyMethod")]
static void MainAssemblyMethod() => Console.WriteLine($"Hello from {nameof(MainAssemblyMethod)}");

static int Main()
private IntPtr programHandle;

public Tests()
{
IntPtr methodAddress = IntPtr.Zero;
IntPtr programHandle = IntPtr.Zero;

programHandle = NativeLibrary.GetMainProgramHandle();
if (programHandle == IntPtr.Zero)
{
return 1;
}

if (NativeLibrary.TryGetExport(programHandle, "MainAssemblyMethod", out methodAddress))
{
var MainAssemblyMethodPtr = (delegate* unmanaged <void>) methodAddress;
MainAssemblyMethodPtr();
}
else
{
return 2;
}

if (NativeLibrary.TryGetExport(programHandle, "ReferencedAssembly1Method", out methodAddress))
{
var ReferencedAssembly1MethodPtr = (delegate* unmanaged <void>) methodAddress;
ReferencedAssembly1MethodPtr();
}
else
{
return 3;
}

if (NativeLibrary.TryGetExport(programHandle, "ReferencedAssembly2Method", out methodAddress))
{
// must not be exposed from ReferencedAssembly2 assembly
return 4;
}

return 100;
Assert.NotEqual(IntPtr.Zero, programHandle);
}

[Fact]
public void ExportFromMainAssembly_IsExported()
{
IntPtr methodAddress = IntPtr.Zero;
bool found = NativeLibrary.TryGetExport(programHandle, "MainAssemblyMethod", out methodAddress);
Assert.True(found);
Assert.NotEqual(IntPtr.Zero, methodAddress);
var MainAssemblyMethodPtr = (delegate* unmanaged<void>)methodAddress;
MainAssemblyMethodPtr();
}

[Fact]
public void ExportFromUnmanagedEntryPointsAssembly_IsExported()
{
IntPtr methodAddress = IntPtr.Zero;
bool found = NativeLibrary.TryGetExport(programHandle, "ReferencedAssembly1Method", out methodAddress);
Assert.True(found);
Assert.NotEqual(IntPtr.Zero, methodAddress);
var ReferencedAssembly1MethodPtr = (delegate* unmanaged<void>)methodAddress;
ReferencedAssembly1MethodPtr();
}

[Fact]
public void ExportFromOtherAssembly_IsNotExported()
{
IntPtr methodAddress = IntPtr.Zero;
bool found = NativeLibrary.TryGetExport(programHandle, "ReferencedAssembly2Method", out methodAddress);
Assert.False(found);
Assert.Equal(IntPtr.Zero, methodAddress);
}

public void Dispose()
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Disable for now.
-->
<DisableProjectBuild Condition="'$(EnableNativeSanitizers)' != ''">true</DisableProjectBuild>
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,5 +20,4 @@
<ItemGroup>
<UnmanagedEntryPointsAssembly Include="ReferencedAssembly1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<CLRTestKind>SharedLibrary</CLRTestKind>
<OutputType>Library</OutputType>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<CLRTestKind>SharedLibrary</CLRTestKind>
<OutputType>Library</OutputType>
</PropertyGroup>

Expand Down
7 changes: 0 additions & 7 deletions src/tests/nativeaot/SmokeTests/ComWrappers/CMakeLists.txt

This file was deleted.

Loading
Loading