Skip to content

[ios-clr] Fix library test failures on Apple mobile platforms#125439

Open
kotlarmilos wants to merge 42 commits intodotnet:mainfrom
kotlarmilos:improvement/ios-clr-library-tests
Open

[ios-clr] Fix library test failures on Apple mobile platforms#125439
kotlarmilos wants to merge 42 commits intodotnet:mainfrom
kotlarmilos:improvement/ios-clr-library-tests

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Mar 11, 2026

Description

This PR fixes CoreCLR library test failures on Apple mobile platforms (iOS, tvOS, MacCatalyst) across simulators and devices. It resolves a native crash in SystemNative_GetOSArchitecture where utsname.machine returns hardware model identifiers instead of CPU architecture strings on real devices, causing a debug assert to fire. It skips tests on iOS/tvOS where the diagnostics IPC socket is unreachable inside the app sandbox. It also removes stale ActiveIssue attributes, updates test skip conditions for platform-specific behavior, fixes ILLink descriptor configurations, increases CI pipeline timeouts.

Copilot AI review requested due to automatic review settings March 11, 2026 12:56
@kotlarmilos kotlarmilos self-assigned this Mar 11, 2026
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone Mar 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to address failing test runs on Apple mobile (iOS/tvOS) when using CoreCLR by re-enabling previously skipped coverage and adjusting test/build configuration so those tests can execute successfully.

Changes:

  • Removed Apple mobile/CoreCLR ActiveIssue skips across several library tests and removed some Apple mobile project exclusions.
  • Updated CustomAttributeDecoderTests to derive the expected System.Type assembly-qualified string from metadata (more resilient to trimming/ILLink differences).
  • Adjusted test build targets to allow preview features/runtime-async on Apple mobile targets.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/tests.proj Removes Apple mobile/CoreCLR exclusions for specific test projects so they run again.
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/InvokeWithRefLikeArgs.cs Re-enables a previously skipped Apple mobile/CoreCLR test (still guarded by Reflection.Emit support).
src/libraries/System.Runtime/tests/System.Globalization.Calendars.Tests/CalendarTestWithConfigSwitch/CalendarTests.cs Re-enables a previously skipped Apple mobile/CoreCLR calendar parsing test.
src/libraries/System.Runtime.Loader/tests/RefEmitLoadContext/RefEmitLoadContextTest.cs Re-enables a previously skipped Apple mobile/CoreCLR Reflection.Emit load-context test.
src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/CustomAttributes/DllImportTests.cs Reorders ActiveIssue attributes (no behavioral code change).
src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs Makes expected System.Type string match decoder output post-trimming and avoids using Type.GetType for enum underlying types.
src/libraries/System.Collections/tests/BitArray/BitArray_CtorTests.cs Re-enables a previously skipped Apple mobile/CoreCLR BitArray clone test.
eng/testing/tests.targets Enables preview features/runtime-async for Apple mobile targets by removing an exclusion.
Comments suppressed due to low confidence (2)

src/libraries/System.Runtime/tests/System.Globalization.Calendars.Tests/CalendarTestWithConfigSwitch/CalendarTests.cs:25

  • The test comment says the legacy behavior "On mobile, this does not throw", but after removing the Apple mobile skip this test will run on Apple mobile and still asserts a FormatException. Either update the comment to the specific platform(s) where it doesn’t throw (e.g., Android-only), or extend the skip/condition so the assertion matches actual mobile behavior.
        [Fact]
        [SkipOnPlatform(TestPlatforms.Android, "Doesn't throw on mobile")]
        public static void TestJapaneseCalendarDateParsing()
        {
            CultureInfo ciJapanese = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() } };

            DateTime dt = new DateTime(1970, 1, 1);
            string eraName = dt.ToString("gg", ciJapanese);

            // Legacy behavior which we used to throw when using a year number exceeding the era max year.
            //
            // On mobile, this does not throw, but instead produces a DateTime w/ 95/01/01
            Assert.ThrowsAny<FormatException>(() => DateTime.Parse(eraName + " 70/1/1 0:00:00", ciJapanese));
        }

src/libraries/System.Collections/tests/BitArray/BitArray_CtorTests.cs:280

  • Re-enabling this test on Apple mobile means it will allocate a BitArray of length int.MaxValue-30 (~256MB+), which is likely to OOM or heavily destabilize test runs on memory-constrained devices. Consider reducing the allocation size while still covering the clone path, or gating this test (e.g., OuterLoop / platform-conditional) for constrained environments.
        [Fact]
        public static void Clone_LongLength_Works()
        {
            BitArray bitArray = new BitArray(int.MaxValue - 30);
            BitArray clone = (BitArray)bitArray.Clone();

            Assert.Equal(bitArray.Length, clone.Length);
        }

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 13, 2026 07:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


You can also share your feedback on Copilot code review. Take the survey.

@kotlarmilos
Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kotlarmilos kotlarmilos changed the title [ios-clr] Remove ActiveIssue references for Apple Mobile in various tests and update project exclusions [ios-clr] Remove ActiveIssue references for CoreCLR library tests on Apple mobile Mar 16, 2026
@kotlarmilos kotlarmilos changed the title [ios-clr] Remove ActiveIssue references for CoreCLR library tests on Apple mobile [ios-clr] Remove ActiveIssue attribute for CoreCLR library tests on Apple mobile Mar 16, 2026
Copilot AI review requested due to automatic review settings April 9, 2026 20:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 3 comments.

@kotlarmilos
Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings April 10, 2026 08:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeFeatureTests.cs:49

  • In DynamicCode_Jit(), the Apple mobile-specific expectation (IsDynamicCodeSupported == true, IsDynamicCodeCompiled == false) was removed, and the remaining else-branch now asserts IsDynamicCodeCompiled == true for all non-NativeAOT runtimes. iOS/tvOS generally do not support JITted dynamic code, so this would make the test incorrect if/when the ActiveIssue gate is removed; consider restoring a platform-specific expectation (or using an existing PlatformDetection predicate that reflects dynamic code compilation support).

@kotlarmilos
Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

}
#if defined(TARGET_IOS) || defined(TARGET_TVOS)
// On iOS/tvOS devices, utsname.machine returns the hardware model rather than the CPU architecture.
// Fall back to the compile-time target architecture.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did this work on mono before?

@vitek-karas
Copy link
Copy Markdown
Member

I created #126754 so that this failure shows as known until we get the fix merged.

@vitek-karas
Copy link
Copy Markdown
Member

@kotlarmilos what failure you're after with the increased timeout.
I've been looking at for example https://dev.azure.com/dnceng-public/public/_build/results?buildId=1367026&view=results - which runs into a timeout for example: https://helixr1107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-heads-main-1e756bffcec04193b2/System.Linq.Tests.Attempt.2/1/console.3b4c1d98.log?helixlogtype=result.

Based on my analysis this would require a change to

<_workItemTimeout Condition="'$(_workItemTimeout)' == '' and '$(TargetsAppleMobile)' == 'true'">01:15:00</_workItemTimeout>
as well, since the actual failures is the timeout of the helix job it seems.

else if (PlatformDetection.IsAppleMobile)
{
Assert.True(RuntimeFeature.IsDynamicCodeSupported);
Assert.False(RuntimeFeature.IsDynamicCodeCompiled);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test looks right. Why remove it?

IsDynamicCodeCompiled should be false on platforms with interpreter (ie AppleMobile and wasm).

};

if (!hasGvmOpenDelegateBug)
// On Apple mobile CoreCLR, open delegates for interface methods are not supported
Copy link
Copy Markdown
Member

@jkotas jkotas Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an issue with more context that we can link from here?

(I assume that we have decided that it is not worth it to do the work required to support these.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Infrastructure-coreclr linkable-framework Issues associated with delivering a linker friendly framework os-ios Apple iOS

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants