Skip to content

[mobile] Skip GetMaxCompressedLength test on mobile platforms#127081

Open
github-actions[bot] wants to merge 2 commits intomainfrom
mobile-fix-android-compression-5d36b3dda8ed8262
Open

[mobile] Skip GetMaxCompressedLength test on mobile platforms#127081
github-actions[bot] wants to merge 2 commits intomainfrom
mobile-fix-android-compression-5d36b3dda8ed8262

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Fixes test failure on Android mobile platforms discovered in build #1383320.

Failure

Test: System.IO.Compression.DeflateEncoderDecoderTests.GetMaxCompressedLength_MatchesNativeCompressBound
Helix job: 730b4b98-bd0b-4578-99bc-0cb6a8eb9289
Work item: System.IO.Compression.Tests
Platform: android-arm, android-arm64 (also affects iOS, tvOS, MacCatalyst)

Root cause

This test compares the managed DeflateEncoder.GetMaxCompressedLength() against the native zlib compressBound() function. The managed implementation (added in #123145) uses the zlib-ng formula for calculating the maximum compressed buffer size:

// From DeflateEncoder.cs, lines 88-94
// This is a managed implementation of zlib-ng's compressBound() formula

However, mobile platforms use classic zlib, not zlib-ng. The classic zlib compressBound() returns different values for certain input sizes, causing assertion failures:

[FAIL] GetMaxCompressedLength_MatchesNativeCompressBound(inputLength: 0)
Assert.Equal() Failure: Values differ
Expected: 13  (classic zlib)
Actual:   11  (zlib-ng formula)

[FAIL] GetMaxCompressedLength_MatchesNativeCompressBound(inputLength: 100)
Assert.Equal() Failure: Values differ
Expected: 113 (classic zlib)
Actual:   122 (zlib-ng formula)

Fix

Skip the test on all mobile platforms by adding nameof(PlatformDetection.IsNotMobile) to the ConditionalTheory attribute. The managed implementation remains correct for its intended use (calculating buffer sizes), but this test cannot validate it against classic zlib.

Testing

The test will be skipped on Android, iOS, tvOS, and MacCatalyst in the runtime-extra-platforms pipeline. Desktop platforms will continue to run the test with zlib-ng.


Note

This PR was created by GitHub Copilot after analyzing mobile platform CI failures in the runtime-extra-platforms pipeline.

Closes #127080

Generated by Mobile Platform Failure Scanner · ● 3.9M ·

The GetMaxCompressedLength_MatchesNativeCompressBound test compares the
managed DeflateEncoder.GetMaxCompressedLength() against the native zlib
compressBound() function. The managed implementation uses the zlib-ng
formula, but mobile platforms (Android and Apple) use classic zlib, which
returns different values for certain input sizes.

This fix adds IsNotMobile to the ConditionalTheory attribute to skip the
test on all mobile platforms where the native zlib implementation differs.

Fixes test failures in build 1383320:
- android-arm Release AllSubsets_Mono
- android-arm64 Release AllSubsets_Mono
- (Preemptively prevents failures on iOS/tvOS/MacCatalyst)

Helix job: 730b4b98-bd0b-4578-99bc-0cb6a8eb9289
Work item: System.IO.Compression.Tests

Closes #127080

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

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 addresses mobile CI failures in System.IO.Compression.Tests by preventing a platform-dependent assertion from running on platforms where the native zlib compressBound() behavior differs from the managed DeflateEncoder.GetMaxCompressedLength() implementation.

Changes:

  • Update GetMaxCompressedLength_MatchesNativeCompressBound to be conditionally skipped on “mobile” platforms via PlatformDetection.IsNotMobile.

@kotlarmilos
Copy link
Copy Markdown
Member

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Apr 17, 2026

However, mobile platforms use classic zlib, not zlib-ng. The classic zlib compressBound() returns different values for certain input sizes, causing assertion failures:

The value returned by GetMaxCompressedLength must match the actual compression algorithm implementation.

Are the values returned by GetMaxCompressedLength algorithm that was copy&pasted from zlib-ng valid for the classic zlib? Are there cases where GetMaxCompressedLength returns smaller number than what the payload is going to compress into using classic zlib?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mobile] Skip mobile-incompatible tests in System.IO.Compression and System.Runtime.Loader

3 participants