Skip to content

Commit

Permalink
Enable NativeAOT runtime tests on MacCatalyst (#102882)
Browse files Browse the repository at this point in the history
This PR updates the CLRTest.Execute.Bash.targets file to set the apple run command for MacCatalyst. The command apple just-run used on Apple mobile is not permitted, and apple test requires the a test runner. Additionally, it is necessary to locate Info.plist in the Contents/ directory and the binary in Contents/MacOS/ within the bundle.

---------

Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
  • Loading branch information
kotlarmilos and ivanpovazan authored Jul 25, 2024
1 parent b656871 commit d2425e9
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,77 @@ jobs:
creator: dotnet-bot
interpreter: true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)

#
# Build the whole product using Native AOT and run runtime tests
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: Release
runtimeFlavor: coreclr
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
isMacCatalystOnlyBuild: ${{ parameters.isMacCatalystOnlyBuild }}
platforms:
- maccatalyst_x64
- maccatalyst_arm64
variables:
# map dependencies variables to local variables
- name: librariesContainsChange
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
- name: monoContainsChange
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_NativeAOT_RuntimeTests
buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(_BuildConfig)
timeoutInMinutes: 180
# extra steps, run tests
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
parameters:
testGroup: innerloop
postBuildSteps:
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
testBuildArgs: tree nativeaot/SmokeTests /p:BuildNativeAOTRuntimePack=true
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)

#
# Build the whole product using Native AOT with the App Sandbox entitlement and run runtime tests
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: Release
runtimeFlavor: coreclr
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
isMacCatalystOnlyBuild: ${{ parameters.isMacCatalystOnlyBuild }}
platforms:
- maccatalyst_x64
- maccatalyst_arm64
variables:
# map dependencies variables to local variables
- name: librariesContainsChange
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
- name: monoContainsChange
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_NativeAOT_RuntimeTests_AppSandbox
buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(_BuildConfig)
timeoutInMinutes: 180
# extra steps, run tests
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
parameters:
testGroup: innerloop
postBuildSteps:
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
testBuildArgs: tree nativeaot/SmokeTests /p:BuildNativeAOTRuntimePack=true /p:DevTeamProvisioning=adhoc /p:EnableAppSandbox=true
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)
2 changes: 1 addition & 1 deletion src/libraries/sendtohelix-mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<Target Name="PrepareForBuildHelixWorkItems_Mobile">

<PropertyGroup Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'maccatalyst'">
<PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true'">
<AppleTestTarget Condition="'$(TargetOS)' == 'iossimulator'">ios-simulator-64</AppleTestTarget>
<AppleTestTarget Condition="'$(TargetOS)' == 'tvossimulator'">tvos-simulator</AppleTestTarget>
<AppleTestTarget Condition="'$(TargetOS)' == 'ios'">ios-device</AppleTestTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if("${HARDENED_RUNTIME}")
set_target_properties(%ProjectName% PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "app.entitlements")
add_custom_command(
TARGET %ProjectName% POST_BUILD
COMMAND if test \"$CODE_SIGN_IDENTITY\"\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
COMMAND if test \"$CODE_SIGN_IDENTITY\" && ls -1 $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib 2>/dev/null | grep -q .\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
)
endif()
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if("${HARDENED_RUNTIME}")
set_target_properties(%ProjectName% PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "app.entitlements")
add_custom_command(
TARGET %ProjectName% POST_BUILD
COMMAND if test \"$CODE_SIGN_IDENTITY\"\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
COMMAND if test \"$CODE_SIGN_IDENTITY\" && ls -1 $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib 2>/dev/null | grep -q .\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
)
endif()
endif()
Expand Down
31 changes: 30 additions & 1 deletion src/tests/Common/CLRTest.Execute.Bash.targets
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ CLRTestExitCode=$?
CLRTestExpectedExitCode=0
]]>
</BashCLRTestLaunchCmds>
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and ('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'maccatalyst')">
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and ('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator')">
<![CDATA[
__Command=""
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
Expand All @@ -484,6 +484,35 @@ $__Command $HARNESS_RUNNER apple just-run %5c
-v
CLRTestExitCode=$?
# Exit code of xharness is zero when tests finished successfully
CLRTestExpectedExitCode=0
]]>
</BashCLRTestLaunchCmds>
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetOS)' == 'maccatalyst'">
<![CDATA[
__Command=""
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
__Command+=" $__TestDotNetCmd"
else
__Command+=" dotnet"
fi
if [ ! -z "$XHARNESS_CLI_PATH" ]; then
# When running in CI, we only have the .NET runtime available
# We need to call the XHarness CLI DLL directly via dotnet exec
HARNESS_RUNNER="exec $XHARNESS_CLI_PATH"
else
HARNESS_RUNNER="xharness"
fi
$__Command $HARNESS_RUNNER apple run %5c
--app="${__TestBinaryBase}/${__Category}.app" %5c
--output-directory="$__OutputDir" %5c
--expected-exit-code=100 %5c
--targets maccatalyst %5c
-v
CLRTestExitCode=$?
# Exit code of xharness is zero when tests finished successfully
CLRTestExpectedExitCode=0
]]>
Expand Down
6 changes: 3 additions & 3 deletions src/tests/Common/helixpublishwitharcade.proj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
SuperPmiCollect=$(_SuperPmiCollect)
</_PropertiesToPass>

<_PropertiesToPass Condition="'$(TargetOS)' == 'browser' Or '$(TargetsAndroid)' == 'true' Or '$(TargetsiOS)' == 'true' Or '$(TargetsiOSSimulator)' == 'true' Or '$(TargetstvOS)' == 'true' Or '$(TargetstvOSSimulator)' == 'true'">
<_PropertiesToPass Condition="'$(TargetOS)' == 'browser' Or '$(TargetsAndroid)' == 'true' Or '$(TargetsAppleMobile)' == 'true'">
$(_PropertiesToPass);
IncludeDotNetCli=$(IncludeDotNetCli);
DotNetCliRuntime=$(DotNetCliRuntime);
Expand Down Expand Up @@ -623,7 +623,7 @@
<TimeoutPerTestInMilliseconds Condition=" '$(TimeoutPerTestInMinutes)' != '' ">$([System.TimeSpan]::FromMinutes($(TimeoutPerTestInMinutes)).TotalMilliseconds)</TimeoutPerTestInMilliseconds>
<WaitForWorkItemCompletion>true</WaitForWorkItemCompletion>
<_XUnitParallelMode>collections</_XUnitParallelMode>
<_XUnitParallelMode Condition=" '$(TargetsAndroid)' == 'true' or '$(TargetsiOSSimulator)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOSSimulator)' == 'true' or '$(TargetstvOS)' == 'true'">none</_XUnitParallelMode>
<_XUnitParallelMode Condition=" '$(TargetsAndroid)' == 'true' or '$(TargetsAppleMobile)' == 'true'">none</_XUnitParallelMode>
<_XUnitParallelMode Condition=" '$(LongRunningGCTests)' == 'true' ">none</_XUnitParallelMode>
<_XUnitParallelMode Condition=" '$(GcSimulatorTests)' == 'true' ">none</_XUnitParallelMode>
<XUnitRunnerArgs>-parallel $(_XUnitParallelMode) -nocolor -noshadow -xml testResults.xml</XUnitRunnerArgs>
Expand Down Expand Up @@ -761,7 +761,7 @@
<HelixCorrelationPayload Include="$(CoreRootDirectory)" />

<!-- Browser-Wasm and iOS platforms follow a very different workflow, which is currently out of scope of the Log Checker. It's not useful on any platform that uses xharness. -->
<HelixCorrelationPayload Include="$(XUnitLogCheckerDirectory)" Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetsiOSSimulator)' != 'true' and '$(TargetstvOS)' != 'true' and '$(TargetstvOSSimulator)' != 'true'" />
<HelixCorrelationPayload Include="$(XUnitLogCheckerDirectory)" Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsAppleMobile)' != 'true'" />
<HelixCorrelationPayload Condition="'$(TestWrapperTargetsWindows)' == 'true'" Include="dotnet-sos">
<Destination>sos</Destination>
<Uri>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/flat2/dotnet-sos/$(DotnetSosVersion)/dotnet-sos.$(DotnetSosVersion).nupkg</Uri>
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftAbiStress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftAbiStress)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftCallbackAbiStress)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftErrorHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftErrorHandling)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftIndirectResult/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftIndirectResult)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftInvalidCallConv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftInvalidCallConv)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftRetAbiStress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftRetAbiStress)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
5 changes: 4 additions & 1 deletion src/tests/Interop/Swift/SwiftSelfContext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")

set(SOURCE SwiftSelfContext)

if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
set(SWIFT_PLATFORM "macosx")
set(SWIFT_PLATFORM_SUFFIX "")
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
endif()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
Expand Down
13 changes: 7 additions & 6 deletions src/tests/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
</PropertyGroup>

<PropertyGroup>
<DevTeamProvisioning>-</DevTeamProvisioning>
<DevTeamProvisioning Condition="'$(DevTeamProvisioning)' == ''">-</DevTeamProvisioning>
<AppleGenerateAppBundle>true</AppleGenerateAppBundle>
<GenerateXcodeProject>true</GenerateXcodeProject>
<AppleBundleDir>$(AppDir)</AppleBundleDir>
Expand Down Expand Up @@ -460,14 +460,15 @@

<!-- This target moves app bundles to the payload directory -->
<Target Name="AfterAppleBuild">
<!-- Apparently MSBuild cannot move directories and recursively copying a
a directory requires writing some sort of recursive traversal
logic yourself. -->
<!-- MSBuild cannot move directories or recursively copy content. -->
<ItemGroup>
<RecursiveCopyHack Include="$(AppBundlePath)/**/*.*" />
<BundleContent Include="$(AppBundlePath)/**/*.*" />
</ItemGroup>
<MakeDir Directories="$(FinalPath)" />
<Copy SourceFiles="@(RecursiveCopyHack)" DestinationFolder="$(FinalPath)/%(RecursiveDir)" />
<!-- MacCatalyst requires Contents/Info.plist and Contents/MacOS/ApplicationBinary -->
<Copy Condition="'$(TargetOS)' == 'maccatalyst' AND '%(BundleContent.Filename)%(BundleContent.Extension)' == 'Info.plist'" SourceFiles="@(BundleContent)" DestinationFolder="$(FinalPath)/Contents/%(RecursiveDir)" />
<Copy Condition="'$(TargetOS)' == 'maccatalyst' AND '%(BundleContent.Filename)%(BundleContent.Extension)' != 'Info.plist'" SourceFiles="@(BundleContent)" DestinationFolder="$(FinalPath)/Contents/MacOS/%(RecursiveDir)" />
<Copy Condition="'$(TargetOS)' != 'maccatalyst'" SourceFiles="@(BundleContent)" DestinationFolder="$(FinalPath)/%(RecursiveDir)" />
<RemoveDir Directories="$(AppBundlePath)" />
<Message Importance="High" Text="Final app: $(FinalPath)" />
</Target>
Expand Down

0 comments on commit d2425e9

Please sign in to comment.