Skip to content

Commit d2425e9

Browse files
Enable NativeAOT runtime tests on MacCatalyst (#102882)
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>
1 parent b656871 commit d2425e9

14 files changed

Lines changed: 145 additions & 20 deletions

File tree

eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,77 @@ jobs:
7777
creator: dotnet-bot
7878
interpreter: true
7979
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
80+
81+
#
82+
# Build the whole product using Native AOT and run runtime tests
83+
#
84+
- template: /eng/pipelines/common/platform-matrix.yml
85+
parameters:
86+
jobTemplate: /eng/pipelines/common/global-build-job.yml
87+
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
88+
buildConfig: Release
89+
runtimeFlavor: coreclr
90+
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
91+
isMacCatalystOnlyBuild: ${{ parameters.isMacCatalystOnlyBuild }}
92+
platforms:
93+
- maccatalyst_x64
94+
- maccatalyst_arm64
95+
variables:
96+
# map dependencies variables to local variables
97+
- name: librariesContainsChange
98+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
99+
- name: monoContainsChange
100+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
101+
jobParameters:
102+
testGroup: innerloop
103+
nameSuffix: AllSubsets_NativeAOT_RuntimeTests
104+
buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(_BuildConfig)
105+
timeoutInMinutes: 180
106+
# extra steps, run tests
107+
extraVariablesTemplates:
108+
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
109+
parameters:
110+
testGroup: innerloop
111+
postBuildSteps:
112+
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
113+
parameters:
114+
creator: dotnet-bot
115+
testBuildArgs: tree nativeaot/SmokeTests /p:BuildNativeAOTRuntimePack=true
116+
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)
117+
118+
#
119+
# Build the whole product using Native AOT with the App Sandbox entitlement and run runtime tests
120+
#
121+
- template: /eng/pipelines/common/platform-matrix.yml
122+
parameters:
123+
jobTemplate: /eng/pipelines/common/global-build-job.yml
124+
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
125+
buildConfig: Release
126+
runtimeFlavor: coreclr
127+
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
128+
isMacCatalystOnlyBuild: ${{ parameters.isMacCatalystOnlyBuild }}
129+
platforms:
130+
- maccatalyst_x64
131+
- maccatalyst_arm64
132+
variables:
133+
# map dependencies variables to local variables
134+
- name: librariesContainsChange
135+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
136+
- name: monoContainsChange
137+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
138+
jobParameters:
139+
testGroup: innerloop
140+
nameSuffix: AllSubsets_NativeAOT_RuntimeTests_AppSandbox
141+
buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(_BuildConfig)
142+
timeoutInMinutes: 180
143+
# extra steps, run tests
144+
extraVariablesTemplates:
145+
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
146+
parameters:
147+
testGroup: innerloop
148+
postBuildSteps:
149+
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
150+
parameters:
151+
creator: dotnet-bot
152+
testBuildArgs: tree nativeaot/SmokeTests /p:BuildNativeAOTRuntimePack=true /p:DevTeamProvisioning=adhoc /p:EnableAppSandbox=true
153+
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)

src/libraries/sendtohelix-mobile.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<Target Name="PrepareForBuildHelixWorkItems_Mobile">
4242

43-
<PropertyGroup Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'maccatalyst'">
43+
<PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true'">
4444
<AppleTestTarget Condition="'$(TargetOS)' == 'iossimulator'">ios-simulator-64</AppleTestTarget>
4545
<AppleTestTarget Condition="'$(TargetOS)' == 'tvossimulator'">tvos-simulator</AppleTestTarget>
4646
<AppleTestTarget Condition="'$(TargetOS)' == 'ios'">ios-device</AppleTestTarget>

src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if("${HARDENED_RUNTIME}")
5050
set_target_properties(%ProjectName% PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "app.entitlements")
5151
add_custom_command(
5252
TARGET %ProjectName% POST_BUILD
53-
COMMAND if test \"$CODE_SIGN_IDENTITY\"\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
53+
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
5454
)
5555
endif()
5656
endif()

src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if("${HARDENED_RUNTIME}")
5959
set_target_properties(%ProjectName% PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "app.entitlements")
6060
add_custom_command(
6161
TARGET %ProjectName% POST_BUILD
62-
COMMAND if test \"$CODE_SIGN_IDENTITY\"\; then codesign -fs \"$CODE_SIGN_IDENTITY\" $CODESIGNING_FOLDER_PATH/Contents/Resources/*.dylib\; fi
62+
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
6363
)
6464
endif()
6565
endif()

src/tests/Common/CLRTest.Execute.Bash.targets

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ CLRTestExitCode=$?
457457
CLRTestExpectedExitCode=0
458458
]]>
459459
</BashCLRTestLaunchCmds>
460-
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and ('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'maccatalyst')">
460+
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and ('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator')">
461461
<![CDATA[
462462
__Command=""
463463
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
@@ -484,6 +484,35 @@ $__Command $HARNESS_RUNNER apple just-run %5c
484484
-v
485485
CLRTestExitCode=$?
486486
487+
# Exit code of xharness is zero when tests finished successfully
488+
CLRTestExpectedExitCode=0
489+
]]>
490+
</BashCLRTestLaunchCmds>
491+
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetOS)' == 'maccatalyst'">
492+
<![CDATA[
493+
__Command=""
494+
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
495+
__Command+=" $__TestDotNetCmd"
496+
else
497+
__Command+=" dotnet"
498+
fi
499+
500+
if [ ! -z "$XHARNESS_CLI_PATH" ]; then
501+
# When running in CI, we only have the .NET runtime available
502+
# We need to call the XHarness CLI DLL directly via dotnet exec
503+
HARNESS_RUNNER="exec $XHARNESS_CLI_PATH"
504+
else
505+
HARNESS_RUNNER="xharness"
506+
fi
507+
508+
$__Command $HARNESS_RUNNER apple run %5c
509+
--app="${__TestBinaryBase}/${__Category}.app" %5c
510+
--output-directory="$__OutputDir" %5c
511+
--expected-exit-code=100 %5c
512+
--targets maccatalyst %5c
513+
-v
514+
CLRTestExitCode=$?
515+
487516
# Exit code of xharness is zero when tests finished successfully
488517
CLRTestExpectedExitCode=0
489518
]]>

src/tests/Common/helixpublishwitharcade.proj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
SuperPmiCollect=$(_SuperPmiCollect)
110110
</_PropertiesToPass>
111111

112-
<_PropertiesToPass Condition="'$(TargetOS)' == 'browser' Or '$(TargetsAndroid)' == 'true' Or '$(TargetsiOS)' == 'true' Or '$(TargetsiOSSimulator)' == 'true' Or '$(TargetstvOS)' == 'true' Or '$(TargetstvOSSimulator)' == 'true'">
112+
<_PropertiesToPass Condition="'$(TargetOS)' == 'browser' Or '$(TargetsAndroid)' == 'true' Or '$(TargetsAppleMobile)' == 'true'">
113113
$(_PropertiesToPass);
114114
IncludeDotNetCli=$(IncludeDotNetCli);
115115
DotNetCliRuntime=$(DotNetCliRuntime);
@@ -623,7 +623,7 @@
623623
<TimeoutPerTestInMilliseconds Condition=" '$(TimeoutPerTestInMinutes)' != '' ">$([System.TimeSpan]::FromMinutes($(TimeoutPerTestInMinutes)).TotalMilliseconds)</TimeoutPerTestInMilliseconds>
624624
<WaitForWorkItemCompletion>true</WaitForWorkItemCompletion>
625625
<_XUnitParallelMode>collections</_XUnitParallelMode>
626-
<_XUnitParallelMode Condition=" '$(TargetsAndroid)' == 'true' or '$(TargetsiOSSimulator)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOSSimulator)' == 'true' or '$(TargetstvOS)' == 'true'">none</_XUnitParallelMode>
626+
<_XUnitParallelMode Condition=" '$(TargetsAndroid)' == 'true' or '$(TargetsAppleMobile)' == 'true'">none</_XUnitParallelMode>
627627
<_XUnitParallelMode Condition=" '$(LongRunningGCTests)' == 'true' ">none</_XUnitParallelMode>
628628
<_XUnitParallelMode Condition=" '$(GcSimulatorTests)' == 'true' ">none</_XUnitParallelMode>
629629
<XUnitRunnerArgs>-parallel $(_XUnitParallelMode) -nocolor -noshadow -xml testResults.xml</XUnitRunnerArgs>
@@ -761,7 +761,7 @@
761761
<HelixCorrelationPayload Include="$(CoreRootDirectory)" />
762762

763763
<!-- 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. -->
764-
<HelixCorrelationPayload Include="$(XUnitLogCheckerDirectory)" Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetsiOSSimulator)' != 'true' and '$(TargetstvOS)' != 'true' and '$(TargetstvOSSimulator)' != 'true'" />
764+
<HelixCorrelationPayload Include="$(XUnitLogCheckerDirectory)" Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsAppleMobile)' != 'true'" />
765765
<HelixCorrelationPayload Condition="'$(TestWrapperTargetsWindows)' == 'true'" Include="dotnet-sos">
766766
<Destination>sos</Destination>
767767
<Uri>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/flat2/dotnet-sos/$(DotnetSosVersion)/dotnet-sos.$(DotnetSosVersion).nupkg</Uri>

src/tests/Interop/Swift/SwiftAbiStress/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
33

44
set(SOURCE SwiftAbiStress)
55

6-
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
6+
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
77
set(SWIFT_PLATFORM "macosx")
88
set(SWIFT_PLATFORM_SUFFIX "")
9+
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
10+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
11+
endif()
912
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
1013
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
1114
endif()

src/tests/Interop/Swift/SwiftCallbackAbiStress/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
33

44
set(SOURCE SwiftCallbackAbiStress)
55

6-
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
6+
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
77
set(SWIFT_PLATFORM "macosx")
88
set(SWIFT_PLATFORM_SUFFIX "")
9+
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
10+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
11+
endif()
912
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
1013
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
1114
endif()

src/tests/Interop/Swift/SwiftErrorHandling/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
33

44
set(SOURCE SwiftErrorHandling)
55

6-
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
6+
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
77
set(SWIFT_PLATFORM "macosx")
88
set(SWIFT_PLATFORM_SUFFIX "")
9+
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
10+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
11+
endif()
912
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
1013
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
1114
endif()

src/tests/Interop/Swift/SwiftIndirectResult/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
33

44
set(SOURCE SwiftIndirectResult)
55

6-
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_OSX)
6+
if (NOT SWIFT_COMPILER_TARGET AND CLR_CMAKE_TARGET_APPLE)
77
set(SWIFT_PLATFORM "macosx")
88
set(SWIFT_PLATFORM_SUFFIX "")
9+
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
10+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
11+
endif()
912
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
1013
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
1114
endif()

0 commit comments

Comments
 (0)